我有一个Gridview As Follows:
<asp:GridView ID="PartnerView" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" CssClass="GridViewStyle"
GridLines="None" DataKeyNames="Partnerid" Width="900px">
<Columns>
<asp:BoundField DataField="Partnername" HeaderText="Partner Name" />
<asp:BoundField DataField="partnertype" HeaderText="Type"/>
<asp:BoundField DataField="Contact" HeaderText="Contact" />
<asp:BoundField DataField="City" HeaderText="City"/>
<asp:BoundField DataField="State" HeaderText="State"/>
<asp:BoundField DataField="Country" HeaderText="Country" />
<asp:BoundField DataField="email" HeaderText="Email ID" />
<asp:TemplateField HeaderText="Details">
<ItemTemplate>
<asp:LinkButton ID="Show_Button" Text="Show" runat="server" OnClick="Show_Button_click"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
我在gridview里面有LinkBUtton ....现在我想要当我点击gridview里面的LinkBUtton我想得到那个特定行的数据.....在下一页..
答案 0 :(得分:1)
通过LinkButton的NamingContainer获取GridViewRow:
protected void Show_Button_click(Object sender, EventArgs e)
{
LinkButton Show_Button = (LinkButton)sender;
GridViewRow row = (GridViewRow)Show_Button.NamingContainer;
// now you can get all other fields via FindControl(in case it's a TemplateField)
// or via row.Cells[index].Text
// Then Response.Redirect to the other page and pass appropriate URL-Parameters
}