471,350 Members | 1,118 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Nested Repeaters

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 object, and an ArrayList of Region objects.
I want to display this hierarchy, and in the inner ArrayList of Region
objects I need to access the Id field of the parent Region object.

<asp:repeater id="outer" runat="server">

<ItemTemplate>
<%# ((RegionMenuItem)Container.DataItem).FromRegion.Na me %> <br>

<asp:repeater id="inner" runat="server" DataSource='<%#
((RegionMenuItem)Container.DataItem).ToRegions %>'>
<ItemTemplate>
&nbsp; <%# ((Region)Container.DataItem).Name %> + <%# outerrepeater
region id %> ??? how this ???
</ItemTemplate>
</asp:repeater>

<ItemTemplate>

</asp:repeater>
Thanks for any help,
Peter

Dec 5 '05 #1
1 3701
Hi,
Interesting situation. Obviously you cannot use Container.DataItem to refer
to the parent.
I would keep a reference to the parent Container.DataItem in a protected
variable declared in the code behind. This variable is accesible to the
inner repeater. so the only thing you need to do is update it when the
external repeater bind the data, like :
<asp:repeater id="outer" runat="server">

<ItemTemplate>
<%# KeepReference( Container.DataItem ) %>

<asp:repeater id="inner" runat="server" DataSource='<%#
((RegionMenuItem)Container.DataItem).ToRegions %>'>
<ItemTemplate>
<%# ((Region) OuterReferenceToItem).Name %>
</ItemTemplate>
</asp:repeater>
in the code behind:
protected object OuterReferenceToItem;
protected void KeepReference ( object o ) { OuterReferenceToItem = o; }
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Peter Kirk" <pk@alpha-solutions.dk> wrote in message
news:O7****************@tk2msftngp13.phx.gbl...
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 object, and an ArrayList of Region objects.
I want to display this hierarchy, and in the inner ArrayList of Region
objects I need to access the Id field of the parent Region object.

<asp:repeater id="outer" runat="server">

<ItemTemplate>
<%# ((RegionMenuItem)Container.DataItem).FromRegion.Na me %> <br>

<asp:repeater id="inner" runat="server" DataSource='<%#
((RegionMenuItem)Container.DataItem).ToRegions %>'>
<ItemTemplate>
&nbsp; <%# ((Region)Container.DataItem).Name %> + <%# outerrepeater
region id %> ??? how this ???
</ItemTemplate>
</asp:repeater>

<ItemTemplate>

</asp:repeater>
Thanks for any help,
Peter

Dec 5 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Machi | last post: by
reply views Thread by kettch | last post: by
2 posts views Thread by Matt Jensen | last post: by
1 post views Thread by mavrick_101 | last post: by
4 posts views Thread by =?Utf-8?B?SmFtZXMgR2V1cnRz?= | last post: by
2 posts views Thread by Josh | last post: by
PrinsonG
1 post views Thread by PrinsonG | last post: by
1 post views Thread by andrew.douglas11 | last post: by
3 posts views Thread by Leon Mayne | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.