Persisting Dynamic DataGrid and Data Across Postbacks

janessaallen used Ask the Experts™
I have a datagrid that I built dynamically and I have a question ...

I found this article about persisting a gridview ...
but i cannot seem to figure out how to cache the gridview prior to restoring.  Are there any examples out there?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
One approach I have used before is the cache the underlying data source.  So, for example, grab the database data as a DataTable/DataSet and then save it to viewstate.  Then bind it to the datagrid/gridview.  The cached data will remain after postback, and can be re-bound if needed.

Note however that caching of any datasource increases the size of the page quite dramatically!

Dim dt as DataTable = GetMyDataFromDataBase()
ViewState("_dt") = dt
MyGridView.DataSource = ViewState("_dt")

Open in new window

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial