我有一个下拉列表:的FindControl - 找不到下拉列表
<asp:DropDownList ID="ddlGoalKeeper" runat="server">
</asp:DropDownList>
一个不错的小家伙。我有一些代码找到它:
DropDownList myControl1 = (DropDownList)Page.FindControl("ddlGoalKeeper");
不..这只是我的myControl1
不被设置......所以当我后来在我的代码尝试设置为true可见,这是行不通的。
任何想法?
为什么你使用Page.Findcontrol访问下拉?为什么不使用“ddlGoalKeeper”来设置可见的 –
使用'ddlGoalKeeper.Visible'时的错误? – V4Vendetta
这很可能是Repeater的一部分,或者类似的东西。在这种情况下,你不会用这样的逻辑找到它,你必须使用ItemDataBound事件并处理那里的控件。 –