数据绑定之前的 ASP.NET Repeater 模板子控件可见性
我有一个包含 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
try this: