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.
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.