product page has datalist control with paging implemented by gridview control, ProductDetail is the second page with back button which will take the user to the previous page.
The problem is when i go to second page in the datalistcontrol and click back button in productdetail page, even the browser back button dosent work, the previous page is not displayed and gives me "Page not found" Error. Any ideas how to make it work
<input id="Button1" type="button" value="Back to Product List" onclick="javascript:history.go(-1)" class ="btn"/>
This is Products.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["p"] != null)
{
CategoryID = c.ToInteger(Request.QueryString["p"].ToString());
}
if (!(IsPostBack))
{
DisplayProduct();
}
}
protected void DisplayProduct()
{
System.Data.SqlClient.SqlConnection Con = new System.Data.SqlClient.SqlConnection();
Con.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"];
System.Data.SqlClient.SqlCommand Cmd = new System.Data.SqlClient.SqlCommand();
Cmd.Connection = Con;
Cmd.CommandType = CommandType.StoredProcedure;
Cmd.Parameters.Add("@CategoryID", SqlDbType.Int);
Cmd.Parameters["@CategoryID"].Value = CategoryID;
Con.Open();
Cmd.CommandText = "name";
SqlDataAdapter da = new SqlDataAdapter(Cmd);
DataSet mydt = new DataSet();
da.Fill(mydt);
int nRowCount = mydt.Tables[0].Rows.Count;
int maxrecords = (this.dgPager.CurrentPageIndex * this.dgPager.PageSize);
da.Fill(mydt, maxrecords, this.dgPager.PageSize, "name");
this.dgPager.VirtualItemCount = nRowCount;
this.dgPager.DataSource = mydt.Tables[1].DefaultView;
this.dgPager.DataBind();
this.dList.DataSource = mydt.Tables[1].DefaultView;
this.dList.DataBind();
lblPageIndex.Text = this.dgPager.CurrentPageIndex.ToString();
Session["PageIndex"] = lblPageIndex.Text.Trim();
if (Con.State == ConnectionState.Open)
{
Con.Close();
Cmd = null;
Con = null;
}
}
Thank you, Shilpa.