Friday 10 August 2012

How to Create TreeView Menu


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>

<body>
    <form id="form1" runat="server">
    <div>
    <asp:treeview ID ="tr1" runat="server" DataSourceID="SiteMapDataSource1"
            Font-Bold="True" Font-Size="14pt" ForeColor="Blue" ImageSet="Simple" ></asp:treeview>
        <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
      
    </div>
    </form>
</body>
</html>





Create Web.sitemap file
Step:
1)    Right click on Project Explorer
2)    Add New Items
3)    Select
















4)    Click Add
5)    Write below code in that file.                                                                                                         
         

<?xml version="1.0" encoding="utf-8" ?>
<siteMap  >
    <siteMapNode url="" title="Root"  description="">
      <siteMapNode url="" title="a"  description=" Root:a" >

        <siteMapNode url="" title="a1"  description="a:a1" />
        <siteMapNode url="" title="a2"  description="a:a2" />
        <siteMapNode url="" title="a3"  description="a:a3" />
       
      </siteMapNode>
      <siteMapNode url="" title="b"  description="Root:b" >

        <siteMapNode url="" title="b1"  description="b:b1" />
        <siteMapNode url="" title="b2"  description="b:b2" />
        <siteMapNode url="" title="b3"  description="b:b3" />

      </siteMapNode>
   
  </siteMapNode>
</siteMap>



1)    Now Select
2)    Then click Smart Tag of Treeview control
3)    Choose Datasource




4)    Select new datasource.

5)    Select Site Map
6)    Then click Ok

2 comments:

Rakesh said...

Good work Rahul,keep it up!

Ramu kumar Gupta said...

Thanks Rakesh Sir