4

我在中继器中有一个中继器,如何使用下面的代码:

<input type="hidden" value='<%# Container.ItemIndex %>' />

指向第一个中继器?

4

2 回答 2

7

这个问题类似;虽然它谈到从 访问属性<HeaderTemplate>,但感觉它应该从<ItemTemplate>.

所以试试<%# ((RepeaterItem)Container.Parent.Parent).ItemIndex %>

如果这不起作用,您可能需要更多.Parents. 尝试暂时将处理程序附加到内部中继器,并使用属性返回与aspx中给出的相同对象ItemDataBound的事实。所以基本上评估等等,直到你找到另一个。然后在你的 aspx 中使用相同数量的s。RepeaterItemEventArgs ItemContainere.Item.Parente.Item.Parent.ParentRepeaterItem.Parent

于 2012-05-23T13:09:45.600 回答
0

来自 MSDN:如何使用嵌套中继器控件显示分层数据

这篇文章有几年的历史了,但内容就是你要找的。

于 2012-05-23T12:51:34.347 回答