如何从代码隐藏访问用户控件的公共属性?

时间:2022-10-19 22:23:28

I have a user control in a repeater that I need to pass data to during the databound event, so I've created two public properties in the control. How do I access these properties from the page's codebehind class?

我在转发器中有一个用户控件,我需要在数据绑定事件期间传递数据,所以我在控件中创建了两个公共属性。如何从页面的代码隐藏类中访问这些属性?

1 个解决方案

#1


4  

During the databind event in the repeater?

在转发器中的数据绑定事件期间?

MyUserControl myControl = (MyUserControl)e.item.FindControl("NameInASPX");
myControl.MyCustomProperty = foo;

#1


4  

During the databind event in the repeater?

在转发器中的数据绑定事件期间?

MyUserControl myControl = (MyUserControl)e.item.FindControl("NameInASPX");
myControl.MyCustomProperty = foo;