asp.net – 在后面的代码中无法识别嵌套的Repeater

我有一个嵌套的转发器设置,但后面的代码中没有识别子转发器控件.它甚至没有添加到设计器文件中.我在aspx和ascx页面上尝试了这个但是两者都给出了同样的问题.
<asp:Repeater ID="RepeaterParent" runat="server">
    <ItemTemplate>

        <asp:Repeater ID="RepeaterChild" runat="server">
        </asp:Repeater>

    </ItemTemplate>
</asp:Repeater>

如果在页面上,后面的代码只识别RepeaterParent而不识别RepeaterChild.

有人可以帮我从这里出去吗?
非常感谢!

解决方法

与转发器(或模板)控件中使用的任何其他控件一样,您需要使用FindControl检索控件.

因此,在父项的项数据绑定事件处理程序中,您将执行以下操作:

var childRepeater = RepeaterParent.FindControl("RepeaterChild") as Repeater;

相关文章

这篇文章主要讲解了“WPF如何实现带筛选功能的DataGrid”,文...
本篇内容介绍了“基于WPF如何实现3D画廊动画效果”的有关知识...
Some samples are below for ASP.Net web form controls:(fr...
问题描述: 对于未定义为 System.String 的列,唯一有效的值...
最近用到了CalendarExtender,结果不知道为什么发生了错位,...
ASP.NET 2.0 page lifecyle ASP.NET 2.0 event sequence cha...