|
-
Jun 25th, 2008, 10:49 AM
#1
[RESOLVED] Not all child rows showing in repeater
I thought I had my previous thread resolved over nesting a third-level repeater, but it seems now that the third level that displays the files only shows the first child, not the rest. The second-level repeater displays all children correctly. Does anyone know why this is the case?
Code:
<asp:Repeater ID="rptAll" runat="server">
<ItemTemplate>
<p>Group: <%#DirectCast(Container.dataitem, Data.DataRowView)("groupid")%></p>
<asp:Repeater ID="rptChildren" runat="server" DataSource='<%# DirectCast(Container.dataitem, Data.DataRowView).CreateChildView("Groups_FileCategories") %>'>
<ItemTemplate>
<p>Category: <%#DirectCast(Container.dataitem, Data.DataRowView)("CategoryID")%> <%#DirectCast(Container.DataItem, Data.DataRowView)("GroupID")%></p>
<asp:Repeater ID="rptFiles" runat="server" DataSource='<%# DirectCast(Container.Dataitem, Data.DataRowView).CreateChildView("FileCategories_Files") %>'>
<ItemTemplate>
<p>File: <%#DirectCast(Container.DataItem, Data.DataRowView)("FileName")%></p>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
**Update - I have checked the dataset, and all five records are in the files table, and the relationships have to be correct or else the first record wouldn't even show...
Last edited by gigemboy; Jun 25th, 2008 at 11:05 AM.
-
Jun 25th, 2008, 11:55 AM
#2
Re: Not all child rows showing in repeater
I moved the datasource code to the codebehind, and the Files_ItemDataBound event fires all five times for the files, yet only the first ones in each group are displayed on the page...
Code:
'codebehind for itemdatabound
Protected Sub Groups_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs)
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
Dim MyRpt As Repeater = e.Item.FindControl("rptChildren")
If MyRpt IsNot Nothing Then
MyRpt.DataSource = DirectCast(e.Item.DataItem, Data.DataRowView).CreateChildView("Groups_FileCategories")
MyRpt.DataBind()
End If
End If
End Sub
Protected Sub Categories_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs)
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
Dim MyRpt As Repeater = e.Item.FindControl("rptFiles")
If MyRpt IsNot Nothing Then
MyRpt.DataSource = DirectCast(e.Item.DataItem, Data.DataRowView).CreateChildView("FileCategories_Files")
MyRpt.DataBind()
End If
End If
End Sub
Protected Sub Files_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs)
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
'****** GETS HERE ALL FIVE TIMES, yet only three show (two are in the same group) ******
End If
End Sub
'source of markup with repeater code...
<asp:Repeater OnItemDataBound="Groups_ItemDataBound" ID="rptAll" runat="server">
<ItemTemplate>
<h4><%#DirectCast(Container.dataitem, Data.DataRowView)("Description")%></h4>
<asp:Repeater OnItemDataBound="Categories_ItemDataBound" ID="rptChildren" runat="server">
<ItemTemplate>
<h5><%--group categories--%><%#DirectCast(Container.DataItem, Data.DataRowView)("Description")%></h5>
<asp:Repeater ID="rptFiles" OnItemDataBound="Files_ItemDataBound" runat="server">
<ItemTemplate>
<p><%#Container.DataItem("FileName")%></p>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
-
Jun 25th, 2008, 12:39 PM
#3
Re: Not all child rows showing in repeater
Ok.. went to lunch... came back, re-ran the code, and now all of the file children are showing... Subway is the answer! geeez....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|