Click here to Skip to main content
Rate this: bad
good
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 at 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 at 9-Jan-13 4:39am
   
Thanks.. Do I just have to include the itemDataBinding event and call

Page.DataBind()

from within it?
Christian Graus at 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
0 Sergey Alexandrovich Kryukov 510
1 CPallini 330
2 OriginalGriff 225
3 George Jonsson 120
4 ChauhanAjay 104
0 OriginalGriff 6,474
1 Sergey Alexandrovich Kryukov 6,190
2 CPallini 5,180
3 George Jonsson 3,574
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 9 Jan 2013
Copyright © CodeProject, 1999-2014
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