Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to pass form1 gridview data to the new form gridview by using session
Posted
Comments
hitech_s 17-Oct-11 5:58am    
means datatable from form1 to form2?
DGKumar 17-Oct-11 6:01am    
no no default.aspx to default2.aspx
hitech_s 17-Oct-11 6:57am    
ok from default.aspx to default2.aspx? only table or gridview

if so put table in session in default.aspx page and retrieve in default2.aspx page

1 solution

C#
dt=new datatable();
ad=new sqldatadapter("select * from table",con)
ad.fill(dt);
Session["dataset"] = dt;
if(dt.rows.count>0)
{
   GridView1.DataSource = dt;
   GridView1.DataBind();
}

and now transferring the data from one page grid to another page

C#
protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            loadgrid();
        }
    }
    private void loadgrid()
    {
        DataTable dset = new DataTable();
        dset = (DataTable)Session["dataset"];
        if (dset.Rows.Count > 0)
        {
            GridView1.DataSource = dset;
            GridView1.DataBind();
        }
    }


regards,

Anilkumar.D
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900