Click here to Skip to main content

pinky1810 asked:

Open original thread
I have a gridview which gets loaded on click of button and in the gridview i have button on click of which i navigate to another page. and in second page i have a back buttobn to navigate to the gridview page. but when i am navigating back to the page the grid view is not retaning the values.plzz help
 
This is code in first page where i have my grid on click of button
 protected void BtnviewEmployee_Click(object sender, EventArgs e)
{
  if (DdlCity.SelectedIndex == 0)
        {
            cityid = branchid = deptid = 0;
        }
        else
        {
            cityid=Convert.ToInt64(DdlCity.SelectedValue.ToString());
            branchid=Convert.ToInt64(DdlBranch.SelectedValue.ToString());
            if (branchid == 0)
            {
                deptid = 0;
            }
            else
            {
                deptid = Convert.ToInt64(DdlDepartment.SelectedValue.ToString());
 
            }
 
        }
        
       
        countryid = Convert.ToInt64(Ddlcountry.SelectedValue.ToString());
        if (countryid != 0 && cityid != 0 && branchid != 0 && deptid != 0)
        {
            dsinfo = bl.BsearchEmp(countryid, cityid, branchid, deptid);
        }
        else if (countryid != 0 && cityid != 0 && branchid != 0)
        {
            dsinfo = bl.searchEmployee(countryid, cityid, branchid);
        }
        else if (countryid != 0 && cityid != 0 )
        {
            dsinfo = bl.searchEmployee(countryid, cityid);
        }
        else
        {
            dsinfo = bl.searchEmployee(countryid);
        }
 

        
       
        Session["mydataset"] = dsinfo;
        GridView1.DataSource = (DataSet)Session["mydataset"];
        GridView1.DataBind();
        BtnDumpToExcel.Visible = true;
        BtnPrint.Visible = true;
}
  protected void Get_Employee_Id_from_grid(object sender, EventArgs e)
    {
        Button btn= sender as Button;
        if (btn != null)
        {
            string Employee_Id = btn.CommandArgument;
            
            Session["Gridview_Employee_id"] = Employee_Id;
 
            Response.Redirect("ViewEmployeeDetail.aspx");
        }
after coming back from ViewEmployeeDetail.aspx i want to see the same grid which is loaded before.
and my grid is in update panel ang i made my button as a trigger to that grid.
 
please advice..
Tags: ASP.NET

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid