Hi Andla,
The viewstate is maintained automatically across postbacks by the
ASP.NET Framework.
The viewstate is read when a page is posted to the server.The viewstate is
restored just before the page is
sent back to the browser.
The viewstate is saved in the state bag using hidden
fields that contain state encoded in a string variable.
State Bag is a data structure containing attribute/value pairs,stored as
string associated with objects.
If you want to preserve the values which are not associated with
any particular control
and if you wish to preserve those values across postbacks you can store
these values is the Pages's state bag.
For example when an Itemcommand event happens in your
datagrid,the browser handles the client side event
to post back to the server which send an event message to the server as
well.Viewstate information is used in handling events.
The server determines if the Itemcommand event has an event
handler associated with it and if there is,the event handler code
is executed at the server.The event message is send to the server by HTTP
POST.ASP.NET automatically do all this for you.What
you have to do is create your event handlers.
Since there is data posted back and forth with every
post,if there is large amount of data you need to handle,
in your datagrid with the EnnableViewState is true ,the page loading can be
very slow and the page size can be too big.
You could use paging in scenarios like this if needed.
However you can disable view state of the datagrid and handle
events using certain guidelines.
Here is an article on this :
http://authors.aspalliance.com/JimRo...agridDiet.aspx
Hope this helps.
Marshal Antony
..NET Developer
http://www.dotnetmarshal.com
"andla" <an**********@mail.mcse.ms> wrote in message
news:an**********@mail.mcse.ms...
Hi,
How does events fire in a datagrid.
I know about the problem if turning the viewstate off the events will
not fire properly even if I rebind the control in every postback. So
then I started to think how does .Net do it if I turn the viewstate
on.
If you use the Request.Form then you can get all the controls that
existed in the previous postback and the hidden field with viewstate. I
suspect that the event is embedded in this viewstate or something that
will create events to fire in the codebehind.
I would appreciate some help in figuring out how this machinery works.
Then maybe it is possible to handle this downside with datagrid.
Yours sincerely
Andla
andla
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message395193.html