Reputation: 59
I have a 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>
And i have the LinkBUtton inside the gridview....Now i want that when i click on the LinkBUtton inside the gridview i want to get the data only of that particular row.....in the next page..
Upvotes: 0
Views: 2557
Reputation: 460360
You get the GridViewRow via the LinkButton's NamingContainer:
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
}
Upvotes: 1