0
訪問CheckListBox通過的FindControl我有這樣的表單視圖和formview_databound()方法:不能在FormView控件
<asp:FormView ID="frm" runat="server" DataKeyNames="Id" DataSourceID="dsSelectedProduct">
<ItemTemplate>
<asp:BulletedList ID="blstCatlist" DataTextField="Name" DataValueField="Id" runat="server"></asp:BulletedList>
</itemTemplate>
</asp:FormView>
和
if (frm.CurrentMode == FormViewMode.ReadOnl
{
var blstCatlist = frm.FindControl("blstCatlist") as BulletedList;
}
但blsCatlist
是null
。 我真的很困惑!因爲可以在找到它formview_Inserting()事件,但在ChangingMode和changedMode無法找到它並且引用爲空。
其實我想在ItemTemplate和EditTemplate中的CheckBoxList中綁定一個bulletList。
親愛@giammin,我知道這一點。它不起作用。我利用你的解決方案 – Mohammadreza
@Edalat無論如何,你的控件不在插入模式的模板中 – giammin