Hi chetan,
Check this example. Now please take its reference and correct your code.
HTML
CS.aspx
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" />
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:BoundField DataField="Country" HeaderText="Country" />
<asp:TemplateField HeaderText="View">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" PostBackUrl='<%# Eval("Id", "~/DetailsCS.aspx?Id={0}") %>'>
View</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Code
CS.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.AddRange(new System.Data.DataColumn[3] {
new System.Data.DataColumn("Id"), new System.Data.DataColumn("Name"), new System.Data.DataColumn("Country") });
dt.Rows.Add("1,5,6", "John Hammond", "United States");
dt.Rows.Add("2", "Mudassar Khan", "India");
dt.Rows.Add("3", "Suzanne Mathews", "France");
dt.Rows.Add("4", "Robert Schidner", "Russia");
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
DetailsCS.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
if (!string.IsNullOrEmpty(Request.QueryString["Id"]))
{
Response.Write("Id is: <b>" + Request.QueryString["Id"] + "</b>");
}
}
}
Screenshot