Hi ahlaj77,
You can pass the BookID to the second page through query string. For this scenario, we can implement by setting the “View” hyperlink dynamicaly in code behind. For your reference, please refer to the following code:
************ HomePage.aspx.cs **************
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"
onrowdatabound="GridView1_RowDataBound">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" Target="_blank" Text="View" runat="server"></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="ID" DataField="ID" />
<asp:BoundField HeaderText="Name" DataField="Name" />
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
************ HomePage.aspx.cs **************
protected void Page_Load(object sender, EventArgs e)
{
DataTable table = new DataTable();
if (!Page.IsPostBack)
{
table.Columns.Add("ID",typeof(int));
table.Columns.Add("Name", typeof(string));
table.Rows.Add(1,"abc");
table.Rows.Add(2, "efg");
GridView1.DataSource = table;
GridView1.DataBind();
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
HyperLink link = (HyperLink)e.Row.FindControl("HyperLink1");
link.NavigateUrl = string.Format("http://YourWebSite/ViewBookReview.aspx?BookID={0}",e.Row.Cells[1].Text);
}
}
Then in ViewBookReview.aspx we can get the BookID and pass it to stored proecedure. You can see detailed information about how to pass variables between pages using query string from the following link:
Passing variables between pages using QueryString
http://www.codeproject.com/KB/aspnet/QueryString.aspx