ViewState problems for inherited TreeNode class. (2.0 framework)

K

ketan.shah

I inherited the TreeNode since I wanted to get more attributes into the
checkbox. So I create my own checkbox on PreRenderText(). The problem
now is that I want to save the state of the attributes so that on a
page postback, I can get the checkbox in the same state as it was
before the the postback. I started by overriding the SaveViewState()
(by adding the attribute values to the arraylist provided by the
base.SaveViewState object) and LoadViewState() methods. The problem I
am facing is that if I add the attributes to the saveviewstate object,
they are not persisted in the next postback. Also, the LoadViewState()
method is never called. Could anyone please point out if I am missing
something?


Here is the code snippet for the SaveViewState()

=======================================
protected override object SaveViewState()
{
object[] viewState = base.SaveViewState() as object[];
ArrayList list = viewState[0] as ArrayList; // getting the
arraylist where the default values were stored.
list.Add(this._state); ------> adding my attribute to the
view state object.
return (viewState as object);
}

=======================================

Thanks,
-K.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top