Reputation: 8480
I have a Repeater inside a Repeater, how can a use the code below:
<input type="hidden" value='<%# Container.ItemIndex %>' />
pointing to the first repeater?
Upvotes: 4
Views: 2828
Reputation: 50104
This question is similar; although it talks about accessing a property from the <HeaderTemplate>
, it feels like it should work from the <ItemTemplate>
.
So try <%# ((RepeaterItem)Container.Parent.Parent).ItemIndex %>
If this doesn't work, you may need more .Parent
s. Try attaching an ItemDataBound
handler to the inner repeater temporarily, and use the fact that the RepeaterItemEventArgs
Item
property returns the same object as Container
gives in the aspx. So basically evaluate e.Item.Parent
, e.Item.Parent.Parent
etc. until you find the one that is another RepeaterItem
. Then use the same number of .Parent
s in your aspx.
Upvotes: 7
Reputation: 49413
From MSDN: How To Display Hierarchical Data by Using Nested Repeater Controls
The article is a few years old but the content is what you're looking for.
Upvotes: 0