System.Web.UI.WebControls Namespace TreeView Class
.NET Framework version 2.0
Returns a collection of TreeNode objects that represents the root nodes in a TreeView control.
Script |
[ TreeNodeCollection variable = ] TreeView.Nodes |
The property is read/write with no default value.
Use the Nodes collection to programmatically obtain information about each root node in a TreeView control. This collection is typically used to iterate through all the root nodes, or to access a specific root node in the tree.
NOTE: A typical tree structure has only one root node; however, you can add multiple root nodes to the TreeView control.
The Nodes property can also be used to programmatically add, insert, or remove TreeNode objects in the collection. Any updates to the collection are automatically reflected in the TreeView control after the next round trip to the server.
To access the child nodes of a root or parent node, use the ChildNodes property of the node ( or the subsequent parent-level node ) to navigate down the node hierarchy.
The following example shows how to programmatically add TreeNode objects to the Nodes collection of a TreeView control.
TreeNode newNode = new TreeNode ( nodeText, nodeValue );
newNode.NavigateUrl = webPageUrl;
menuObject.Nodes.Add ( newNode );
Show me
TreeView Members TreeNode