如何在动态添加的用户控件中访问控件?

时间:2013-12-05 16:24:52

标签: c# user-controls

我有一个带有表单元素的UserControl,我动态加载子表单:

subForm = Page.LoadControl("/subforms/ReservationType_" + value + ".ascx")
DynamicFormPart.Controls.Add(subForm);  

如何在动态加载的子表单上访问表单元素的值?

这些东西不起作用:

var gameCheckBox = _subForm.FindControl("GameCheckBox") as CheckBox;

var gameCategory = DynamicFormPart.FindControl("GameCategory") as DropDownList;

var checkBoxMtbDistance = this.Page.FindControl("CheckBoxMtbDistance") as CheckBox;

那怎么办呢?谢谢!

0 个答案:

没有答案