Introduction
Found in the project to use the site map of the control, did not summarize this aspect of things, wrote a demo test, here to record, is summed it.
Web.sitemap
1 <?XML version= "1.0" encoding= "Utf-8"?>2 <SiteMapxmlns= "http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >3 <SiteMapNodeURL= "default.aspx"title= "Home"Description="">4 <!--site map node, similar to a tree structure, the parent node includes child nodes, as follows -5 <SiteMapNodeURL=""title= "Organizational Structure"Description="">6 <SiteMapNodeURL= "Departmentmanager.aspx"title= "Department management"Description=""></SiteMapNode>7 <SiteMapNodeURL= "Usermanager.aspx"title= "User Management"Description=""></SiteMapNode>8 </SiteMapNode>9 <SiteMapNodeURL=""title= "Statistical information"Description="">Ten <SiteMapNodeURL= "Vistorstatistics.aspx"title= "Access Statistics"Description=""></SiteMapNode> One <SiteMapNodeURL= "Userinfostatistics.aspx"title= "User Statistics"Description=""></SiteMapNode> A </SiteMapNode> - <SiteMapNodeURL=""title= "System Parameters"Description=""> - <SiteMapNodeURL= "Systemmanage.aspx"title= "System Settings"Description=""></SiteMapNode> the </SiteMapNode> - </SiteMapNode> - </SiteMap>
Master Page
1 <%@ Master Language="C #"AutoEventWireup="true"codebehind="Home.master.cs"Inherits="Wolfy.SiteMapDemo.Home" %>2 3 <!DOCTYPE HTML>4 5 <HTMLxmlns= "http://www.w3.org/1999/xhtml">6 <Headrunat= "Server">7 <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" />8 <title></title>9 <Asp:contentplaceholderID= "Head"runat= "Server">Ten </Asp:contentplaceholder> One </Head> A <Body> - <formID= "Form1"runat= "Server"> - <Div> the - <Asp:contentplaceholderID= "ContentPlaceHolder1"runat= "Server"> - </Asp:contentplaceholder> - <Asp:treeviewID= "TreeView1"runat= "Server"></Asp:treeview> + <Asp:sitemappathID= "SiteMapPath1"runat= "Server"></Asp:sitemappath> - + </Div> A </form> at </Body> - </HTML>
To bind a data source to a TreeView
New Data source
Generated HTML code:
1 <Asp:treeviewID= "TreeView1"runat= "Server"DataSourceID= "SiteMapDataSource1"></Asp:treeview>2 <Asp:sitemapdatasourceID= "SiteMapDataSource1"runat= "Server" />3 <Asp:sitemappathID= "SiteMapPath1"runat= "Server"></Asp:sitemappath>
Browse results
Summarize
Things are very simple, but also a knowledge point, record. Ning wrong kill 1000, don't let one!
Code: Link: http://pan.baidu.com/s/1jGsoYii Password: z88m