472,960 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,960 software developers and data experts.

Nested repeaters -- accessing data from outer repeater

With nested repeaters, how can I access the outer repeater's DataItem
from the inner repeater?

Here's a snippet from my aspx:

<asp:repeater id="OuterRepeater" runat="server"
onItemDataBound="PrepareInner">
<ItemTemplate>
<h1>
<%# DataBinder.Eval(Container.DataItem, "number") %>
<%# DataBinder.Eval(Container.DataItem, "title") %>
</h1>
<asp:repeater id="InnerRepeater" runat="server">
<ItemTemplate>
<h2>
<%# DataBinder.Eval(OuterContainer.DataItem, "number") %>.
<%# DataBinder.Eval(Container.DataItem, "number") %>
<%# DataBinder.Eval(Container.DataItem, "title") %>
</h2>
</ItemTemplate>
</asp:repeater>
</ItemTemplate>
</asp:repeater>

And here's the method that binds the inner repeater's data source on
each pass using the relation:

public void PrepareInner(Object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item
|| e.Item.ItemType == ListItemType.AlternatingItem)
{
((Repeater)e.Item.FindControl("InnerRepeater")).Da taSource=
((DataRowView)e.Item.DataItem).CreateChildView("Re lation");
((Repeater)e.Item.FindControl("InnerRepeater")).Da taBind();
}
}

Where I used the (invalid) variable "OuterContainer" in the aspx, I
would like to access the Container from OuterRepeater.

Nov 19 '05 #1
1 10633
If you are doing it in the ASPX as you are, you can get at the parent
repeater item by using:

<%#databinder.eval(container,"Parent.Parent.DataIt em")%>

If you are using it the code behind duing an ItemDataBound event, use:

CType(e.Item.Parent.Parent, RepeaterItem).DataItem

BTW, the first parent is the inner Repeater.

Hope this helps.

je*********@gmail.com wrote in news:1128718345.036264.44100
@z14g2000cwz.googlegroups.com:
With nested repeaters, how can I access the outer repeater's DataItem
from the inner repeater?

Here's a snippet from my aspx:

<asp:repeater id="OuterRepeater" runat="server"
onItemDataBound="PrepareInner">
<ItemTemplate>
<h1>
<%# DataBinder.Eval(Container.DataItem, "number") %>
<%# DataBinder.Eval(Container.DataItem, "title") %>
</h1>
<asp:repeater id="InnerRepeater" runat="server">
<ItemTemplate>
<h2>
<%# DataBinder.Eval(OuterContainer.DataItem, "number") %>.
<%# DataBinder.Eval(Container.DataItem, "number") %>
<%# DataBinder.Eval(Container.DataItem, "title") %>
</h2>
</ItemTemplate>
</asp:repeater>
</ItemTemplate>
</asp:repeater>

And here's the method that binds the inner repeater's data source on
each pass using the relation:

public void PrepareInner(Object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item
|| e.Item.ItemType == ListItemType.AlternatingItem)
{
((Repeater)e.Item.FindControl("InnerRepeater")).Da taSource=
((DataRowView)e.Item.DataItem).CreateChildView("Re lation");
((Repeater)e.Item.FindControl("InnerRepeater")).Da taBind();
}
}

Where I used the (invalid) variable "OuterContainer" in the aspx, I
would like to access the Container from OuterRepeater.


Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: DonRex | last post by:
Hello all! I couldn't find a web application-newsgroup for ASP.NET, so I'm sorry if this is the wrong forum! Synopsis: In my webform I have 3 nested repeaters: rpWeeks ----- rpTime
0
by: Ed Allan | last post by:
http://ejaconsulting.com/nestedrepeater/NestedRepeater.txt >-----Original Message----- >Doh! The HTML has all been rendered . . . > >Right click on this link and select 'Save target as ..' >to...
1
by: Peter Kirk | last post by:
Hi in nested repeaters, how do I access data in the "outer" repeater from the "inner" repeater? For example, I have an ArrayList of RegionMenuItem objects. These objects contain a Region...
4
by: =?Utf-8?B?SmFtZXMgR2V1cnRz?= | last post by:
On my page, I have one repeater that contains a literal control and a nested repeater. The nested repeater contains a literal control. Both repeaters are databound with only one object (string). ...
0
by: Adam Knight | last post by:
Hi All, I have a repeater control nested inside another repeater control. The nested (child) repeater control, is bound to an object data source. My problem is, i need to send a data item...
1
by: latinveloper | last post by:
Hello All, I am new to this so I apologize if this question has been asked before. I am working on nesting two data repeaters. The parent repeater displays Categories, and the child repeater...
2
by: Josh | last post by:
I have a nested repeater situation with a Link Button on the nested repeater. However when the link button is clicked I get a postback but the event never takes place. I'm trying to wire up the...
1
by: andrew.douglas11 | last post by:
Hello all, Is it possible to share controls inside a child repeater? Here's the situation: I have a web page that needs to display data grouped by A, and alternatively by B (only one grouping...
3
by: Leon Mayne | last post by:
If I have a datatable which looks like this: Record Id, Group Id, Name 1, 1, Test 1 2, 1, Test 2 3, 2, Test 3 4, 3, Test 4 Is it possible to use nested repeaters to group the information by...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.