Friday, May 18, 2012

How to use view state in asp.net

View state provides page level state management i:e as long as user is in current page state is maintained,as redirected to new page the current page state is lost  and new page state is started .view state can store any type of data   .It is not preferred to store complex type of data as it has to undergo serialization and serialisation every time
View state data is not secured it is simply encoded in  base64 format and because of which is not readable.Any how view state related configuration settings and some properties are available to make the data encrypt/secured
-->View state falls in client state management because no load or values are stored with server
//button_click event
{if(Viewstate["dsdata"]==null)
{
ds=DataHelper.GetData("elect*from emp");
Viewstate["dsdata"]=ds;
}
else
{
ds=(Dataset)Viewstate["dsdata"];
ds=DataHelper.GetData("elect*from emp");
Viewstaae["dsdata"]=ds;
}
GV.DataSource=ds.Table[0];
Gv.DataBind()
}

No comments:

Bel