导航到其他页面后保留Gridveiw [英] Retaining Gridveiw after navigating to other page

查看:67
本文介绍了导航到其他页面后保留Gridveiw的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个gridview,单击该按钮即可加载,在gridview中,我单击该按钮可以导航到另一页.在第二页中,我有一个后部按钮可以导航到gridview页.但是当我导航回该页面时,网格视图没有重新显示这些值.plzzhelp

这是第一页中的代码,点击按钮后我的网格就会出现

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");
        }


从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..

推荐答案

在pageLoad事件上绑定gridview,检查会话并绑定网格.

如果我没看错,则必须在Page_Load事件中编写这些代码
Bind the gridview on pageLoad event , check for the session and bind the grid.

If I am not wrong , you have to write these codes on Page_Load event
GridView1.DataSource = (DataSet)Session["mydataset"]; 
GridView1.DataBind();


这篇关于导航到其他页面后保留Gridveiw的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆