Monday, 30 July 2012

ASP.NET TreeView Control | TreeView Control,SiteMapDataSource Control in ASP.NET | TreeView Control Example in ASP.NET

                         Hi Friends, I already explained some topics in the ASP.NET ,in this article I will explain about the TreeView Control,SiteMapDataSource Control  in ASP.NET
  • TreeView Control is introduced in ASP.NET 2.0.
  • TreeView is used to display hierarchical data.
  • For example, you can use this control when displaying a navigation menu, displaying database records from database tables in a Master/Detail 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.

Let I will explain TreeView Control by using an example.
First of all take one. SiteMap file.
                                      Create one new ASP.NET website.After that Add new Item, select SiteMap  and click OK then web.sitemap file is creted.In the web.sitemap file write the following code.

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="">
  <siteMapNode title="Home" url="" >
    <siteMapNode title="ASP.NET"
      <siteMapNode title="Send mail"
      <siteMapNode title="Introduction to Validation controls"
      <siteMapNode title="VB.NET"
        <siteMapNode title="How to move the text file or Notepad file "
          <siteMapNode title="Update Panel in AJAX"

                                In the above code SiteMap is root tag. SiteMapNode is the Parent node, inside that SiteMapNode are the leaf nodes.
                              Web.sitemap file is created. Let us create a one webForm.Go to the project ,Add New Item select Webform ,name it as aspdotnet-kishore.aspx and click ok then webForm is created.Take one TreeView in navigation parent tag in the ToolBox and SiteMapDataSource in the Data parent tag in the ToolBox and write the following code.

<html xmlns="" >
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
        <asp:TreeView ID="TreeView1" runat="server" DataSourceID ="SiteMapDataSource1">
        <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />

When we run the above code then the output will like in the below figure.

ASP.NET TreeView Control | TreeView Control,SiteMapDataSource Control  in ASP.NET | TreeView Control Example in ASP.NET

No comments:

Post a Comment

© 2012-2018 All Rights Reserved.
The content is copyrighted to Kishore and may not be reproduced on other websites without permission from the owner.