我有一个嵌套的转发器设置,但后面的代码中没有识别子转发器控件.它甚至没有添加到设计器文件中.我在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;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。