Wrox Programmer Forums
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 24th, 2006, 09:52 AM
Registered User
 
Join Date: Aug 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default nested repeater

I am using a nested repeater to generate an unordered list for my site navigation. The problem I have is that I want to generate the following structure.
[list]
<li> item 1 </li>
<li> item 2
[list]
<li>item 2-1 </li>
<li>item 2-2 </li>
<li>item 2-3 </li>
</ul>

</li>

<li>item 3 </li>
</ul>


However what I am getting is [list]
<li> item 1 [list]
</ul>
</li>
<li> item 2
[list]
<li>item 2-1 </li>
<li>item 2-2 </li>
<li>item 2-3 </li>
</ul>

</li>

<li>item 3 [list]
</ul>
</li>
</ul>

Basically the nested child repeater is still writing out its header and footer resulting in[list] </ul> to be generated for every sub item. This means that for every item in my navigation that does not have sub items I still get a drop down due to the[list] and </ul> header and footer tags in the childRepeater. Is there any way I can stop this.

Here's my code. The following runs onLoad of the page.
Sub PopulateMenu()
        Const connectionString As String = "SERVER=localhost;DATABASE=db;Integrated Security=True"

        Dim con As New SqlClient.SqlConnection(connectionString)
        Dim dadCats As New SqlClient.SqlDataAdapter("SELECT tNav.[Nav1ID], tNav.Title, tNav.URL FROM tblNav1 AS tNav ORDER BY tNav.SequenceID", con)
        Dim dadSubCats As New SqlClient.SqlDataAdapter("SELECT tNav.[Nav1ID], tNav.[Nav2ID], tNav.Title, tNav.URL FROM tblNav2 AS tNav ORDER BY tNav.SequenceID", con)

        Dim dst As New DataSet()
        dadCats.Fill(dst, "Sections")
        dadSubCats.Fill(dst, "Categories")


        dst.Relations.Add("Children", _
        dst.Tables("Sections").Columns("Nav1ID"), _
        dst.Tables("Categories").Columns("Nav1ID"))

        parentRepeater.DataSource = dst.Tables("Sections")
        parentRepeater.DataBind()

    End Sub


 Protected Sub parentRepeater_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles parentRepeater.ItemDataBound
        Dim item As RepeaterItem = e.Item
        If item.ItemType = ListItemType.Item Or item.ItemType = ListItemType.AlternatingItem Then
            Dim childRepeater As Repeater = item.FindControl("childRepeater")
            Dim drv As DataRowView = item.DataItem
            childRepeater.DataSource = drv.CreateChildView("children")
            childRepeater.DataBind()
        End If


And in the presentation layer
[list]

<asp:repeater id="parentRepeater" runat="server" OnItemDataBound="parentRepeater_ItemDataBound">
<itemtemplate>
        <li><a href='/sections_<%# Container.DataItem("Nav1ID") %>.aspx' class="nav_separator"><%#DataBinder.Eval(Container .DataItem, "Title")%></a>

             <asp:repeater id="childRepeater" runat="server">
                <HeaderTemplate>
                    [list]
                </HeaderTemplate>
                <itemtemplate>
                       <li><a href='/categories_<%# Container.DataItem("Nav1ID") %>_<%# Container.DataItem("Nav2ID") %>.aspx'><%# Container.DataItem("Title") %></a></li>
                </itemtemplate>
                <FooterTemplate>
                    </ul>
                </FooterTemplate>

            </asp:Repeater>

        </li>
    </itemtemplate>

</asp:Repeater>
</ul>







Similar Threads
Thread Thread Starter Forum Replies Last Post
Nested Repeater Using Stored Procedure kwilliams ASP.NET 2.0 Professional 1 July 21st, 2008 06:49 PM
How to dispaly attributes of xml nested repeater.. vishnu108mishra XML 0 November 15th, 2007 07:38 AM
Accessing Child Controls of Nested Repeater... Jayahar ASP.NET 2.0 Professional 3 October 11th, 2007 01:24 PM
nested repeater ramonjor ASP.NET 2.0 Basics 0 July 31st, 2007 04:18 AM
FindControl in nested repeater chrisk_47 .NET Framework 2.0 0 February 6th, 2007 10:45 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.