Search code examples
asp.netrepeatersitemap

ASP.NET sitemap not displaying child nodes using asp:repeater


The above is my ASP.NET code

<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />                
<ul>
    <asp:Repeater runat="server" ID="menuRepeater" DataSourceID="SiteMapDataSource1">
        <ItemTemplate>
            <li>
                <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("Url") %>' Text='<%# Eval("Title") %>' />
            </li>
        </ItemTemplate>
    </asp:Repeater>
</ul>

and here is the sitemap

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
  <siteMapNode url="~/Default.aspx" title="Homepage">
    <siteMapNode url="~/Login.aspx" title="Login"/>
    <siteMapNode url="~/News.aspx" title="News"/>
    <siteMapNode url="~/Preferences.aspx" title="Preferences"/>
  </siteMapNode>
</siteMap>

The problem with above code is that it only shows the parent node (~/Default.aspx), however when I use the Menu or TreeView control and specify the SiteMapDataSource, everything works properly. Can you please spot where am I wrong?


Solution

  • set ShowStartingNode="false" in SiteMapDataSource markup.