将 ASP.NET 用户控件的属性绑定到父控件的字段之一
如果我需要在 PreRender 之前访问用户控件的属性值,我是否需要将自定义控件基于预先存在的数据控件之一(重复器、列表视图等)?
我的一个用户控件具有 gridview 控件,该控件是根据其所在的用户控件的属性进行配置的。几个关键属性会更改底层记录源的 SQL 语句。我现在遇到的情况是,为 SQL 语句设置 WHERE 语句的属性需要绑定到用户控件的父 FormView 中的值。将表单视图视为显示客户详细信息记录。用户控件获取客户的帐号,然后显示相关表(例如客户联系人姓名)中的数据。由于 gridview 是在控件的预渲染事件之前创建的,因此在预渲染事件中工作似乎效率不高。
看这个问题作为参考: 用户控件上的自定义属性难住了
If I need access to the value of a user control's property BEFORE PreRender, would I need to base the custom control off of one of the preexisting data controls (repeater, listview, etc.)?
One of my user controls features a gridview control that is configured based on the user control's properties on which it resides. Several of the key properties alter the SQL Statement for the underlying recordsource. I'm now in a situation where the property that sets the WHERE statement for the SQL Statement needs to tied to a value in the user control's parent FormView. Think of the formview as displaying a customer detail record. The user control takes the customer's account number and then displays data from a related table such as Customer Contact Names. Since the gridview is created before the control's prerender event, working within the prerender event doesn't seem efficient.
See this question as a reference:
Stumped With Custom Property on User Control
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我说过,当用户控件绑定时,您可以为父控件赋值。
TestIt.ascx - 标记
TestIt.ascx.vb
ASPX - 标记
ASPX.vb
What I said that you can assign value to the parent control when user control binds.
TestIt.ascx - Markup
TestIt.ascx.vb
ASPX - Markup
ASPX.vb