2012-02-17 37 views
0

選擇項目時,不會觸發更改事件。即使在檢查後也不會調用複選框選擇索引更改函數

ASP頁:

<asp:CheckBoxList ID="CheckBoxList1" runat="server" 
    DataSourceID="SqlDataSource1" DataTextField="name" DataValueField="name" 
    OnSelectedIndexChanged="CheckBoxList1_SelectedIndexChanged"> 
</asp:CheckBoxList> 

CS代碼:(此功能未在選擇項目之後調用)

public partial class WebForm1 : System.Web.UI.Page 
    { 
    protected void Page_Load(object sender, EventArgs e) 
    { 

     Chart1.Visible = false; 
    } 

    protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e) 
    { 

     Chart1.Visible = true; 


     CDLDataAccess.dao.Insert("inside"); 
    } 

} 

回答

1

你試圖把.. 的AutoPostBack = 「真」

<asp:CheckBoxList ID="CheckBoxList1" runat="server" AutoPostBack="true" 
    DataSourceID="SqlDataSource1" DataTextField="name" DataValueField="name" 
    OnSelectedIndexChanged="CheckBoxList1_SelectedIndexChanged"> 
</asp:CheckBoxList> 
相關問題