Jimmy D
Jimmy D

Reputation: 5376

Pass datatable to different page to be diaplyed in gridview

I have an aspx page with a gridview control. The code-behind for this page fills a datatable and then displays the datatable in the gridview. I then need to pass the datatable to a separate aspx page and display it again in a gridview on THAT page. I'm not sure how to go about this.

On the second page, in the code-behind, I'll have a simple function that receives a datatable and displays it in a gridview, but what is the best way to do what I'm trying to do? I need the gridview to display on the original page, but also display on the new page.

So... somehow display the gridview on page1, then pop open the new page and pass the datatable to my function? At a loss here.

Upvotes: 0

Views: 2629

Answers (1)

Paritosh
Paritosh

Reputation: 4503

You can try using Sessions, once you display the GridView for the first time, just save the DataTable it loaded into a Session, something like Session["griddata"] = myDataTable. Then in the other page just pull it out of the Session likeDataTable myDataTable = (DataTable)Session["griddata"]; then bind it to the grid.

Upvotes: 2

Related Questions