Click here to Skip to main content
12,444,790 members (51,407 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET
Hi,
I have a repeater which looks at the sitemap provider to obtain the menu items. But the issue is, it is getting only the top level menu items and no submenu item. Below is the code please let me know what I have done wrong here. Thanks

<ul id="menu">
                   <!-- menu rendering starts here -->
                   <asp:Repeater runat="server" ID="rptrMenu" DataSourceID="SiteMapDataSource1" EnableViewState="False">
                       <ItemTemplate>
                           <li><a href="<%# this.ResolveUrl(Eval("Url") as string) %>"><%# Eval("Title") %></a>
                               <asp:Repeater ID="rptrSubmenu" runat="server" DataSource='<%# ((SiteMapNode)Container.DataItem).ChildNodes %>'>
                                   <HeaderTemplate>
                                       <ul>
                                   </HeaderTemplate>
                                   <ItemTemplate>
                                       <li><a href="<%# this.ResolveUrl(Eval("Url") as string) %>"><%# Eval("Title") %></a>
                                           <asp:Repeater ID="Repeater1" runat="server" DataSource='<%# ((SiteMapNode) Container.DataItem).ChildNodes %>'>
                                               <HeaderTemplate>
                                                   <ul>
                                               </HeaderTemplate>
                                               <ItemTemplate>
                                                   <li><a href="<%# this.ResolveUrl(Eval("Url") as string) %>"><%# Eval("Title") %></a></li>
                                               </ItemTemplate>
                                               <FooterTemplate>
                                                   </ul>
                                               </FooterTemplate>
                                           </asp:Repeater>
                                       </li>
                                   </ItemTemplate>
                                   <FooterTemplate>
                                       </ul>
                                   </FooterTemplate>
                               </asp:Repeater>
                           </li>
                       </ItemTemplate>
                   </asp:Repeater>
                   <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false" />
Posted 8-Jan-13 2:27am
Comments
Christian Graus 8-Jan-13 14:34pm
   
You are using asp.net, not asp. Don't say asp, it is something else.

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

I believe that to get an inner repeater to bind, you need to handle the ItemDataBinding event, so you can find it and call DataBind. Otherwise, it will not run, and you won't get your second level.
  Permalink  
Comments
spankyleo123 9-Jan-13 4:39am
   
Thanks.. Do I just have to include the itemDataBinding event and call

Page.DataBind()

from within it?
Christian Graus 9-Jan-13 4:52am
   
If your binding works the way it looks to, I think so. But you may as well do the binding in code as well, if you have to write code at all.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160811.3 | Last Updated 9 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100