Click here to Skip to main content
15,891,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

ASP.NET
<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
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

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.
 
Share this answer
 
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900