Click here to Skip to main content
15,894,254 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
Good Day,

I am storing a huge dataset that may contain thousands of rows into a viewstate.
Is this a good practice to do like this? If not please suggest some other ways of storing dataset.
What is the max capacity of viewstate?

Thx in dav
Posted

Storing huge data in a Viewstate is not recommended. The reasons are;
a) your page becomes very heavy and will take a lot of bandwidth and time to load.
b) ViewState involves extra overload of serializing and deserializing the objects, so involves extra processing time.
c) If not used properly, ViewState will cause performance issues in your page.

So what are your options? You will have to use other alternatives to store the data. Here are some links which will help you understand and use ViewState wisely:
ASP.NET View State Overview[^] (You may directly scroll down to the section - Considerations for Using View State)
ASP.NET State Management Recommendations[^]
ASP.NET 2.0 Performance Guidelines - View State[^]

Hope this helps!
 
Share this answer
 
Comments
m@dhu 22-Apr-11 1:58am    
My 5!
Ankur\m/ 22-Apr-11 2:00am    
Thanks!
Sandeep Mewara 22-Apr-11 2:03am    
My 5++!
:)
Ankur\m/ 22-Apr-11 2:15am    
++ ?! :D :rolleyes:
Sandeep Mewara 22-Apr-11 2:25am    
Abhi aise to 5 hi de sakte hai... via comment to jayda de doon! :)
If you store this much of data in ViewState, then your page will become heavy and will take a lot of time to load, So it is not suggestable to store a lot of data in the ViewState.
 
Share this answer
 
Comments
Harsha 2 22-Apr-11 1:42am    
Thx for reply,

Could you please suggest any alternate way of doing it
nit_singh 22-Apr-11 2:04am    
You can store the data in the Session and when you move out make the Session as null.

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