Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a gridview and its populated from a datatable. I have used Viewstate to hold the data.

Now if I redirect to a new page from this page and again come back to this page, all my datas are lost and the gridview, datatable, viewstate is showing empty.

How can I retain the previous table inspite of page reload?

What I have tried:

I have tried binding the viewstate again but its showing empty
Posted
Updated 3-Aug-17 2:06am

1 solution

Viewstate can have only page accessibility you can not hold data within your app
You can play it within the page. not within the app

For access within app you can use session.

Or in

page load() method

if(!ispostback)
{
//rebind your gried view using datatable
}


And if you are using session then before binding with datatable check the value of your
session variable if it is null then bind with datatable else with stored data in your session variable in above if condition.
 
Share this answer
 

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