Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Can';t在代码隐藏中访问dropdownlist_C#_Asp.net_Code Behind - Fatal编程技术网

C# Can';t在代码隐藏中访问dropdownlist

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.NETWebForms。我这里有一个下拉列表:

  <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在另一个控件中,我看不到它。