K
Keith Patrick
I have a custom subclass of TreeNode that has to store it's own additional
viewstate to itself. However, the problem I run into is that even though
the owning TreeView is itself a subclass that overrides CreateNode(), then
calling TreeNode.LoadViewState(object), all ChildNodes are restored as
TreeNode rather than DerivedTreeNode, so when they themselves have their
viewstates restored, they are receiving modified viewstates (and basically,
my viewstate is new Object[] { base.SaveViewState(), <newViewStateInfo> })
not that haven't had the 2nd element stripped out and thus results in an
InvalidCastException as TreeNode.LoadViewState assumes the vs is of a
different type.
My question is: how can I override TreeNode.LoadViewState such that I can
restore the child node hierarchy with the instances being of the correct
subclass of TreeNode that knows how to handle the modified viewstate?
viewstate to itself. However, the problem I run into is that even though
the owning TreeView is itself a subclass that overrides CreateNode(), then
calling TreeNode.LoadViewState(object), all ChildNodes are restored as
TreeNode rather than DerivedTreeNode, so when they themselves have their
viewstates restored, they are receiving modified viewstates (and basically,
my viewstate is new Object[] { base.SaveViewState(), <newViewStateInfo> })
not that haven't had the 2nd element stripped out and thus results in an
InvalidCastException as TreeNode.LoadViewState assumes the vs is of a
different type.
My question is: how can I override TreeNode.LoadViewState such that I can
restore the child node hierarchy with the instances being of the correct
subclass of TreeNode that knows how to handle the modified viewstate?