数据绑定之前的 ASP.NET Repeater 模板子控件可见性

发布于 2024-09-07 11:27:42 字数 293 浏览 0 评论 0原文

我有一个包含 Repeater 控件的自定义控件。 Repeater 有一个 ItemTemplate。在该项目模板内,我有一个面板,它将隐藏基于“IsEditable”(自定义控件的布尔属性)的内容。我想做的是在中继器进行数据绑定之前设置面板的可见性一次。

我知道我可以执行 onItemDataBound 事件并使用 FindControl 来获取面板,但这似乎有点过多,因为它对于所有行始终可见或不可见,并且我不需要在数据绑定上执行其他操作。

有没有办法在 Repeater 进行数据绑定之前找到 ItemTemplate 中的控件?

I have a custom control which contains a Repeater control. The Repeater has an ItemTemplate. Inside that item template I have a panel which is going to hide something based on "IsEditable" a boolean property of the custom control. What I would like to do is set the panel's visibility once before the Repeater is databound.

I know I could do an onItemDataBound event and use FindControl to get the panel but that seems a little excessive since it will always be either visible or not for all rows and I have no other actions that need to occur on databind.

Is there a way to find the control in the ItemTemplate before the Repeater is databound?

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

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

发布评论

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

评论(1

清眉祭 2024-09-14 11:27:42

试试这个:

<ItemTemplate>
    <asp:Panel Visible='<%# this.IsEditable %>' runat="server">
        editableStuff
    </asp:Panel>
</ItemTemplate>

try this:

<ItemTemplate>
    <asp:Panel Visible='<%# this.IsEditable %>' runat="server">
        editableStuff
    </asp:Panel>
</ItemTemplate>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文