Click here to Skip to main content
13,152,454 members (42,656 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

10.7K views
3 bookmarked
Posted 11 Oct 2013

TreeView

, 13 Oct 2013
Rate this:
Please Sign up or sign in to vote.
The TreeView control can be used  in any situation in which you need to display hierarchical data. For example, you can use this control to provide a

Editorial Note

This articles was originally at wiki.asp.net but has now been given a new home on CodeProject. Editing rights for this article has been set at Bronze or above, so please go in and edit and update this article to keep it fresh and relevant.

The TreeView control can be used in any situation in which you need to display hierarchical data. For example, you can use this control to provide a site navigation, displaying database records from database tables in a Parent/Child relation, displaying the contents of an XML document, or displaying files and folders from the file system. It is also possible for you to programmatically access the TreeView object model to dynamically create trees, populate nodes, set properties and so on. The TreeView control consists of nodes and there are three types of nodes that you can add to a TreeView control.
  • Root - A root node is a node that has no parent node. It has one or more child nodes.
  • Parent - A node that has a parent node and one or more child nodes
  • Leaf - A node that has no child nodes

The easiest way to use the TreeView control is to specify a static set of tree nodes . the following is an example on how to define the TreeView Nodes Declarativley :

<asp:TreeView ID="TreeView1" runat="server">
    <Nodes>
       <asp:TreeNode Text="Products" Value="Products">
         <asp:TreeNode Text="Computers" Value="Computers">
             <asp:TreeNode Text="Brand" Value="Brand"></asp:TreeNode>
             <asp:TreeNode Text="Compatable" Value="Compatable"></asp:TreeNode>
          </asp:TreeNode>
          <asp:TreeNode Text="NoteBooks" Value="NoteBooks"></asp:TreeNode>
          <asp:TreeNode Text="HardDisks" Value="HardDisks"></asp:TreeNode>
          <asp:TreeNode Text="Monitors" Value="Monitors"></asp:TreeNode>
      </asp:TreeNode>
   </Nodes>
</asp:TreeView>

Also you can use the TreeView to provider a Site Navigation capabilities, in this case you need to configure the TreeView  to use the SiteMapDataSource To Dynamicly display the SiteMap Nodes .

The TreeView and Menu Controls can provide a good solution for site Navigation ,specially if they combined with the Roles and Security Trimming Capabilities.

More Resources On TreeView :

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

ASP.NET Community
United States United States
This member doesn't quite have enough reputation to be able to display their biography and homepage.
Group type: Collaborative Group

764 members


You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170924.2 | Last Updated 13 Oct 2013
Article Copyright 2013 by ASP.NET Community
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid