Inheriting from the TreeNode class
- From: "Alexander Walker" <alex@xxxxxxxxxxxxxxx>
- Date: Sun, 15 Jan 2006 05:07:28 -0000
Hello
I have a written a class that inherits from the TreeNode class
I want to use the inherited TreeNode class to attach custom properties to
the nodes in a TreeView web control
I am trying to use the TreeNodePopulate event to read the custom property
when the user expands a node
The problem is that the custom node is not recognised when the event fires
after the page has been rendered
How can I access the custom node during postbacks, I get the feeling that
the custom node isn't being created, even though I've overridden the
CreateNode method, is there something else I should do? Do I need to
override other methods that persist the custom properties of the custom
treenode? Am I doing this the wrong way? Should I take an entirely different
approach?
Here is some of the code
public class CustomTreeView : TreeView
{
protected override TreeNode CreateNode()
{
return new CustomTreeNode();
}
}
public class CustomTreeNode : TreeNode
{
private int customInt;
public int CustomInt
{
get
{
return customInt;
}
set
{
customInt= value;
}
}
}
protected void customTreeView_TreeNodePopulate(object sender,
TreeNodeEventArgs e)
{
CustomTreeNode node = e.Node as CustomTreeNode;
// node == null
// i need to access node.CustomInt
...
}
Thanks
Alex
.
- Follow-Ups:
- RE: Inheriting from the TreeNode class
- From: Steven Cheng[MSFT]
- RE: Inheriting from the TreeNode class
- Prev by Date: Inheriting from the TreeNode class
- Next by Date: FormView - Single Record edit
- Previous by thread: Inheriting from the TreeNode class
- Next by thread: RE: Inheriting from the TreeNode class
- Index(es):
Relevant Pages
|
Loading