我有一個下拉列表:的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事件並處理那裏的控件。 –