ViewState is driving me crazy. Please help!

K

Ken Varn

I have a class that I created that derives from TableRow. I have several of
my own custom properties in my class that are stored in ViewState. These
properties are retained in ViewState just fine. The problem I am having is
that the base class properties are not saved in ViewState. I cannot figure
out why. I have checked to make sure that ViewState is enabled, but it
still is not saving the base class ViewState elements. In particular, the
TableRow.Cells and all controls added to each Cell. And yes, the Cells all
have ViewStateEnabled set to true.

I decided to implement a IStateManager interface in my class and added the
following code for the IStateManager implementation. Not sure if this is
the reason why the base class ViewState is missing. Can someone please
help?

#region IStateManager Members

public new void TrackViewState()
{
base.TrackViewState();
}

public new bool IsTrackingViewState
{
get
{
return base.IsTrackingViewState;
}
}

public new object SaveViewState()
{
return base.SaveViewState();
}

public new void LoadViewState(object state)
{
base.LoadViewState(state);
}

#endregion


--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
 
B

Bill Jones

I had a similar issue when trying to use the Web Form object, Table. None
of the controls within the table, nor the Table itself were being held in
the ViewState no matter how many times I set EnableViewState to true. I
finally determined that the Table object is not serializable and therefore
cannot be maintained in ViewState. Is there any truth to that? I don't
know. If not, why does it have an EnableViewState property? Who knows. I
got it around it by adding the table to a Session variable, and adding and
retrieving the table from the Session variable as needed.

- Bill Jones
Senior Programmer/Analyst
Advanced Career Technologies
(e-mail address removed)
 
S

Scott Mitchell [MVP]

I had a similar issue when trying to use the Web Form object, Table. None
of the controls within the table, nor the Table itself were being held in
the ViewState no matter how many times I set EnableViewState to true. [snip]
If not, why does it have an EnableViewState property?

ALL Web controls have the EnableViewState property. If a control has
this property set to False, it does not generate any view state
information. If it's True (the default), it doesn't imply what type of
view state information it persists. Looking at the Table Web control,
it doesn't implement IStateManager, which implies that it only saves the
state of its own properties, and not its inner content.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top