i ahve grid view where i have used an button on click it redirects to other page now i want to transfer the primarykey value of selected row to other page
this code is of button event
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
Session.Add("id",GridView1.SelectedValue);
Response.Redirect("trail.aspx");
}
this is grid view html
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns = "False"
Font-Names = "Arial" Caption = "Using ImageField" DataKeyNames="ID"
onrowcommand="GridView1_RowCommand">
<Columns>
<asp:BoundField DataField = "ID" HeaderText = "ID" />
<asp:BoundField DataField = "Name" HeaderText = "Image Name" />
<asp:ImageField DataImageUrlField = "ID"
DataImageUrlFormatString = "ImageCSharp.aspx?ImageID={0}"
ControlStyle-Width = "100" ControlStyle-Height = "100"
HeaderText = "Preview Image">
<ControlStyle Height="100px" Width="100px"></ControlStyle>
</asp:ImageField>
<asp:ButtonField Text="Button" />
</Columns>
</asp:GridView>