TreeView Navigation in ASP.Net 2.0 - Declaring the TreeView Nodes
(Page 3 of 5 )
In this step we’ll add the TreeView nodes. A <nodes> element surrounds the individual nodes. Figure 5 declares the <Nodes> element.
Figure 5: The Nodes Element

Each menu item is an <asp:TreeNode> element. We will use attributes to define the menu item’s navigation address and anchor text. We are purposely using the bare minimum code to show how the TreeView works.
Figure 6: The TreeViews Nodes

Note how the hierarchy is formed in Figure 6. If a node has a child then it does not close the asp:TreeNode tag. First it defines the children and then the TreeNode is closed:
Figure 7: Using the XML Hierarchical Structure to Create TreeView Node Parent-Child Relationships

The Shelters element is not closed, so everything under it is a child node. Each of the child nodes is closed, so the hierarchy stops descending for each of them. When the Shelters element is closed, the Parent-Child relationships are complete: Municipal, Private and Mixed are children of the Shelters node.
Next: Treeview DataSource Binding >>
More ASP.NET Articles
More By Caroline Bogart