C# Can';t在代码隐藏中访问dropdownlist
我是新来的,正在学习ASP.NETWebForms。我这里有一个下拉列表:C# Can';t在代码隐藏中访问dropdownlist,c#,asp.net,code-behind,C#,Asp.net,Code Behind,我是新来的,正在学习ASP.NETWebForms。我这里有一个下拉列表: <asp:DropDownList id="DropDownList1" runat="server"> </asp:DropDownList> 由于它位于与页面不同的NamingContainer中,因此需要使用FindControl获取它: DropDownList DropDownList1= (DropDownList)RegisterUserWizardStep.FindCon
<asp:DropDownList id="DropDownList1" runat="server">
</asp:DropDownList>
由于它位于与
页面不同的NamingContainer
中,因此需要使用FindControl
获取它:
DropDownList DropDownList1= (DropDownList)RegisterUserWizardStep.FindControl("DropDownList1");
由于它位于与页面不同的NamingContainer
中,因此需要使用FindControl
获取它:
DropDownList DropDownList1= (DropDownList)RegisterUserWizardStep.FindControl("DropDownList1");
您需要的是:
DropDownList DropDownList1 = (DropDownList)RegisterUserWizardStep.ContentTemplateContainer.FindControl("DropDownList1");
您需要的是:
DropDownList DropDownList1 = (DropDownList)RegisterUserWizardStep.ContentTemplateContainer.FindControl("DropDownList1");
您的DropDownList
是否在另一个控件中?@JustinIurman请参见上面的编辑,如果DropDownList在另一个控件中,我看不到它。您的DropDownList
是否在另一个控件中?@JustinIurman请参见上面的编辑,如果DropDownList在另一个控件中,我看不到它。