|
-
Jun 24th, 2008, 05:48 PM
#1
[RESOLVED] Nested Repeater on Third Level Doesn't Work
Trying to nest a third level repeater, but I seem to be getting a "Public member 'Row' on type 'DataRow' not found." error. The first two nestings work correctly, but the third does not.
To summarize, I have three tables of data in the dataset, with relationships added, the parent being the first table, the child/second parent being table 2, and the final table3 being the final child table. The repeater is meant to show a file list, with each file having a group and category id. The repeater displays the groups, then the categories, then the files listed in each category for each group (like I said, the first two levels, the Groups and Categories is working)
I am not quite sure what the syntax is in source view to access the items at each level, and got lucky with the second level from reading a post and working on it for a little while.
The code for the source view in the nesting looks like this:
Code:
<asp:Repeater ID="rptAll" runat="server">
<ItemTemplate>
<p>Group: <%#DataBinder.Eval(Container.DataItem, "groupid")%></p>
<asp:Repeater ID="rptChildren" runat="server" DataSource='<%# container.dataitem.Row.GetChildRows("Groups_FileCategories") %>'>
<ItemTemplate>
<p>Category: <%#DataBinder.Eval(Container.DataItem, "[""CategoryID""]")%></p>
***************************
'third level nesting, where the problems are
***************************
<asp:Repeater ID="rptFiles" runat="server" DataSource='<%# container.dataitem.Row.GetChildRows("FileCategories_Files") %>'>
<ItemTemplate>
<p>Category: <%#DataBinder.Eval(Container.DataItem, "[""FileID""]")%></p>
</ItemTemplate>
</asp:Repeater>
****************************
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
Now on the second level, I have no idea why categoryid needed "[""CategoryID""]" listed as the item instead of just "categoryid", but it wouldn't work the other way. Now I am thinking that the third level needs something extra, but since I don't really know what I'm doing, I'm not really sure what that is. I need to get the child rows for the second nesting to display the actual file in that category, but am receiving the error posted at the beginning.
Can anyone make any sense of this?
-
Jun 24th, 2008, 06:12 PM
#2
Re: Nested Repeater on Third Level Doesn't Work
Well, When you use .GetChildRows, the types returned are rows, not rowviews, so you can't call another .GetChildRows. So now the question is how can you have a third level if that is the case?
-
Jun 24th, 2008, 07:24 PM
#3
Re: Nested Repeater on Third Level Doesn't Work
1 option is to set the repeater datasource to a public function in your code behind and make that function return a dataset/table/etc with the records.
Your repeater
<asp:Repeater ID="rptFiles" DataSource='myFunction(<%#DataBinder.Eval(Container.DataItem, "columnName")%>)' >
in codebehind
public function myFunction(byVal columnName as string) as datatable
'get/filter data in datatTable or object that suits
'This is called on every row of parient repeater so you don't want to go to the database, best to filter a dataview etc that already has the data
return myDataTable
end function
side note : eval = evil.mendak.objects
Last edited by brin351; Jun 24th, 2008 at 07:30 PM.
-
Jun 24th, 2008, 08:22 PM
#4
Re: Nested Repeater on Third Level Doesn't Work
Finally got it to work using .CreateChildView in the nested datasources (using the relations I had made on the three-table dataset in the codebehind), courtesy of this excellent link on ASP.NET databinding.
Once I got the casting and understood what was going on, it was simple (imagine that?). Below is the re-written code that works...
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>
Last edited by gigemboy; Jun 24th, 2008 at 08:26 PM.
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
|