Reputation: 11
I have a DataTable at page1.aspx and want page2.aspx to read and storage that DataTable so i can freely use this one too.
There is a simple way to do that?
It's only for a college homework so nothig too big or complicated, only a DataTable with simple items.
Upvotes: 1
Views: 82
Reputation: 1656
@NorbertoEscobar offered good solution, but you may use Class to do that. In class you have some function, that will return datatable, or have datatable as it is.
DataTable dt = YourClass.GetMyDataTable();
Or void function:
DataTable dt = new DataTable();
YourClass.FillMyDataTable(dt);
Upvotes: 0
Reputation: 190
you can use a Session variable
in page1 code behind
Session["dt1"] = dtFullGrid;
in page2 code behind
GridView1.DataSource = Session["dt1"];
GridView1.DataBind();
or
Datatable dt2 = new Datatable();
dt2 = (DataTable)Session["dt1"];
Upvotes: 1