Click here to Skip to main content
12,550,593 members (32,938 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


3 bookmarked


, 13 Oct 2013 CPOL
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 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">
       <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 Text="NoteBooks" Value="NoteBooks"></asp:TreeNode>
          <asp:TreeNode Text="HardDisks" Value="HardDisks"></asp:TreeNode>
          <asp:TreeNode Text="Monitors" Value="Monitors"></asp:TreeNode>

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 :


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


About the Author

ASP.NET Community
United States United States
The ASP.NET Wiki was started by Scott Hanselman in February of 2008. The idea is that folks spend a lot of time trolling the blogs, googlinglive-searching for answers to common "How To" questions. There's piles of fantastic community-created and MSFT-created content out there, but if it's not found by a search engine and the right combination of keywords, it's often lost.

The ASP.NET Wiki articles moved to CodeProject in October 2013 and will live on, loved, protected and updated by the community.
Group type: Collaborative Group

741 members

You may also be interested in...


Comments and Discussions

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