Mega Code Archive

 
Categories / ASP.Net / Sitemap
 

Binding a GridView with the SiteMapDataSource control

<%@ Page Language="C#" %> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">     <title>Binding a GridView with the SiteMapDataSource control</title> </head> <body>     <form id="form1" runat="server">     <div>         <asp:SiteMapDataSource runat="Server" ID="SiteMapDataSource1" />                 <asp:GridView ID="gridNavigationLinks" runat="server"            DataSourceID="SiteMapDataSource1" AutoGenerateColumns="false">           <Columns>             <asp:TemplateField>               <ItemTemplate>                 <a href='<%# Eval("Url") %>'><%# Eval("Title") %></a>                 <br/>                 <%# Eval("Description") %>               </ItemTemplate>             </asp:TemplateField>           </Columns>     </asp:GridView>     </div>     </form> </body> </html> File: Web.sitemap <?xml version="1.0" encoding="utf-8" ?> <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >   <siteMapNode url="~/Default.aspx" title="Home">     <siteMapNode url="~/Default.aspx" title="Books">       <siteMapNode url="~/Novels.aspx" title="Novels" />       <siteMapNode url="~/History.aspx" title="History" />       <siteMapNode url="~/Romance.aspx" title="Romance" />     </siteMapNode>     <siteMapNode url="~/Default.aspx" title="Electronics">       <siteMapNode url="~/Cameras.aspx" title="Camera" />       <siteMapNode url="~/Computers.aspx" title="Computer" />     </siteMapNode>     <siteMapNode url="~/Default.aspx" title="DVDs">       <siteMapNode url="~/Horror.aspx" title="Horror" />       <siteMapNode url="~/Kids.aspx" title="Kids" />     </siteMapNode>     <siteMapNode url="~/Default.aspx" title="Computers">       <siteMapNode url="~/Desktop.aspx" title="Desktop" />       <siteMapNode url="~/Laptop.aspx" title="Laptop" />     </siteMapNode>   </siteMapNode> </siteMap>