|
|
 |
| 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 tens of thousands of computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other programmers’ questions, win occasional prizes given to our best members, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
|
 |
|
|
 |

August 24th, 2006, 10:52 AM
|
|
Registered User
|
|
Join Date: Aug 2005
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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>
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |