My code is given below:
protected void gvPdtSubCategory_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvPdtSubCategory.PageIndex = e.NewPageIndex;
Session.Add("PrevpageIndex", gvPdtSubCategory.PageIndex);
if (ddlProduct.SelectedItem.Value == "0")
{
Session.Remove("PdtCat");
ShowPdtSubCat();
}
else
{
ShowPdtCategoryWise();
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (Session["admin"] != null)
{
GetPageAuthentication();
if (!IsPostBack)
{
CatNameBind();
if (Request.UrlReferrer != null)
{
if (Request.UrlReferrer.ToString().Contains("AdmUpdatePdtSubCategory.aspx"))
{
if (Session["PrevPageIndex"] != null)
{
gvPdtSubCategory.PageIndex = (int)Session["PrevPageIndex"];
if (Session["PdtCat"] != null)
{
ShowPdtCategoryWise();
ddlProduct.SelectedItem.Text = Session["PdtCatText"].ToString();
}
else
{
ShowPdtSubCat();
}
}
else
{
ShowPdtSubCat();
}
}
else
{
ShowPdtSubCat();
}
}
else
{
ShowPdtSubCat();
}
}
if (hdnID.Value != "0")
{
DeletePdtSubCat(hdnID.Value, hdTImage.Value, hdLImage.Value , hdTDS.Value , hdEcatalog.Value);
}
}
else
{
// Session.Abandon();
Response.Redirect("Default.aspx");
}
}
Now it is working fine. But i have one problem.
On this page there are two searches. one is Search by Product Category(on select index change of dropdownlist of product category).
Second one is Search by Product name (On select index change of dropdownlist of product name). data in dropdownlist of product name is coming on select index change of product category. If i searched data by category wise. i went to page no. 3. i clicked on edit button. i went to editpage.aspx. I clicked on edit button. After edit i returned back to the page no. 3 of search by product category page. Here in dropdownlist product category name is showing(because i have taken it in session.
The problem is that the product name is not showing after returning back from another page even i take the product name in session. I think that because data in product name is depend on select index change of dropdownlist of product category. so it is coming on return of another. If you have any idea to bring data in product name on return of another page then please suggest me.