![]() |
|
|
|||||||
![]() |
ASP Net - Nested repeaters -- accessing data from outer repeater |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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. jeremystein@gmail.com |
|
|
|
|
#2 |
|
Posts: n/a
|
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. 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. > > cbDevelopment |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Wonderful data input with web reporting tool | freezea | Software | 0 | 09-09-2009 05:30 AM |
| ASP.Net - Data Repeater | vbnetman | General Help Related Topics | 0 | 01-07-2008 11:34 AM |