开发者

Dynamic Controls State Management - View State Vs Database

开发者 https://www.devze.com 2022-12-15 10:57 出处:网络
What is the best option to store data pertaining to dynamic controls.Here is my scenario. At any time around 5 to 15 master tables to retreive from.

What is the best option to store data pertaining to dynamic controls. Here is my scenario.

  1. At any time around 5 to 15 master tables to retreive from.
  2. Dynamic Controls can be of type TextBox, DropDownList, ListBox, GridView.
  3. Master's are not going to change on postback, but page will incur many postbacks in a same session.
  4. I'm using SQLServer 2005 with .NET 2.0

Being more experience开发者_运维技巧d users, Do you suggest to fill items in those controls from database or allow viewstate of each controls to maintain the item list? I'm looking at this from faster performance point of view. Also, Could you please provide reasons for your suggestions.

Any other suggestions are also welcome. Let me know, incase you need more information.

Thanks - Raja


It depends. As Aaron mentioned, everything you store in viewstate has to be uploaded from the client back to the server. For an internet site this normally makes viewstate an incredibly bad place to store tabular data. For an intranet site where the client likely has 100Mbs upload bandwidth that's not as big a deal, and Viewstate may be a better place; this is especially true if the database query to rebuild this data is expensive.

That said, a lot of intranet sites are eventually ported to support home workers and suddenly find themselves working in internet situations, so you may still want to keep internet-like performance limitations in mind. In this case, if your database query ends up being a bottleneck you might consider either an indexed/materialized view or even separate table(s) where you can insert this data temporarily for quick retrieval to help speed things up on that end.


In your case, I'd definitely hit the database for data, and not store any tabular data in the ViewState. Everything stored in the ViewState is sent back to the server from the client every postback. It's unencrypted, used, re-encrypted, then sent back, which is much more costly than querying your database.

Small things like id's and whatnot are good to store in the ViewState, but not whole tables of data.

0

精彩评论

暂无评论...
验证码 换一张
取 消