Thanks for the reply. What I am doing is using a private property rather
than a local variable, something like:
private DataSet PageDataSet
{
get{return (DataSet)ViewState["VsDataSet"];}
set{ViewState["VsDataSet"]=value}
}
This make the persistence to viewstate transparent, but I wanted to be sure
I wasn't incurring any extra overhead.
--
"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Hi,
ViewState collection is populated from serialized string at LoadViewState
phase once on the postback, so it does not basically deserialize it every
time you reference it. But certainly its not bad habit if you make a
reference to it in local variable (less need for casting).
--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"Gandalf" <ga*****@sauron.com> wrote in message
news:u3**************@TK2MSFTNGP12.phx.gbl...
Say I have persisted a DataSet in the ViewState of a page, and that when
the page is posted back I make several references to that dataset like so:
DataSet MyDataSet = (DataSet)ViewState["VsDataSet"]; //C#
Does this have to deserialize the dataset every time it is referenced...
or is it only done once when the page is posted back? I'm just wondering if I
should assign the DataSet to a local variable in the PageLoad method or if
it's OK to continually reference it via the ViewState.
TIA