Hi,
From your description, you're wondering tradeoff between storeing database
records in ASP.NET page's viewstate and query them in every request,
correct?
Based on my understanding, if you're using Databound control(such as
Gridview, DataGrid) to display data queried from database, after you
perform databinding, the viewstate will automatically store those necessary
info for the Gridview/DataGrid to display each rows in sequential requests.
However, the database table based structure is not persisted
automatically. Therefore , I'm wondering what you want to do or what's the
reason that you may need to cache/store the entire database table (e.g.
datatable/dataset) into Viewstate?
For general consideration, I think you can consider the following factors:
1. ViewState is only used for store data which need to reuse between the
same page's multiple post. If you request the page(via HTTP GET) again, the
viewstate(stored in previous request) is no longer available. For data
that need to be persisted between multiple page or requests(not only
postback), I think Session State and Application Cache is better.
2. For impaction, since viewstate is persisted as an html hidden field in
page's html source, if the data you want to store is very large, it will
surely increase your page's response content size and that'll make the page
display or postback slowly for low bandwidth clients(for internet
scenaros). And if you cache large data in SessionState or Application
Cache, that will not impact response stream size, but if that is used
frequently, the server-side memory will have some pressure.
3. If the bottleneck is not at the web application and backend database
server(performing data accessing operations such as query data), I
recommend you query the data from database in every request where you need
to display the data. But if the data is large and really static or
unchangable, you can consider using Application Cache to cache them.
#Using the ASP.NET Application Cache to Make Your Applications Scream
http://www.developer.com/net/net/article.php/1477771
#ASP.NET Caching Overview
http://msdn.microsoft.com/en-us/library/ms178597.aspx
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------