gpt4 book ai didi

asp.net - 嵌套的中继器在后面的代码中未被识别

转载 作者:行者123 更新时间:2023-12-04 13:29:23 25 4
gpt4 key购买 nike

我设置了嵌套中继器,但在后面的代码中无法识别子中继器控件。它甚至没有被添加到设计器文件中。我在一个 aspx 和一个 ascx 页面上试过这个,但都给出了同样的问题。

<asp:Repeater ID="RepeaterParent" runat="server">
<ItemTemplate>

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

</ItemTemplate>
</asp:Repeater>

页面上有这个,后面的代码只能识别RepeaterParent,但不能识别RepeaterChild。

有谁可以帮我离开这里吗?
非常感谢!

最佳答案

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

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

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

关于asp.net - 嵌套的中继器在后面的代码中未被识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4470870/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com