如何访问GridView Onrowdatabound和Repeater Control内部的控制控制

发布于 2025-02-03 01:30:46 字数 810 浏览 2 评论 0原文

我想在GridView Onrowdatabound中找到LBLTITLE控件,而GridView处于中继器控制中。你能帮忙吗?谢谢。

<asp:Repeater ID="parentRepeater" runat="server" OnItemDataBound="OnItemDataBound" >
<ItemTemplate>
    <asp:GridView ID="childRepeater" runat="server" OnRowDataBound="GridView1_RowDataBound" DataKeyNames="BookID">
            <Columns>
                <asp:TemplateField>
                   <ItemTemplate>
                                   
                     <asp:Label ID="lblTitle" runat="server"  ></asp:Label>

                   </ItemTemplate>
                </asp:TemplateField>
                                         
             </Columns>
          </asp:GridView>
        </ItemTemplate>

&lt;/asp:中继器&gt;

I want to find lblTitle control in GridView OnRowDataBound, and gridview is in the Repeater control. Can you please help? Thank you.

<asp:Repeater ID="parentRepeater" runat="server" OnItemDataBound="OnItemDataBound" >
<ItemTemplate>
    <asp:GridView ID="childRepeater" runat="server" OnRowDataBound="GridView1_RowDataBound" DataKeyNames="BookID">
            <Columns>
                <asp:TemplateField>
                   <ItemTemplate>
                                   
                     <asp:Label ID="lblTitle" runat="server"  ></asp:Label>

                   </ItemTemplate>
                </asp:TemplateField>
                                         
             </Columns>
          </asp:GridView>
        </ItemTemplate>

</asp:Repeater>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我不会写诗 2025-02-10 01:30:46
protected void OnItemDataBound(object sender, RepeaterItemEventArgs e) {
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
        GridView childRepeater = e.Item.FindControl("childRepeater") as GridView;
        Label lblTotal = childRepeater.FooterRow.FindControl("lblTotal") as Label;
        lblTotal.Text = childRepeater.Rows.Count.ToString();
    }
}
protected void OnItemDataBound(object sender, RepeaterItemEventArgs e) {
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
        GridView childRepeater = e.Item.FindControl("childRepeater") as GridView;
        Label lblTotal = childRepeater.FooterRow.FindControl("lblTotal") as Label;
        lblTotal.Text = childRepeater.Rows.Count.ToString();
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文