复选框选中的索引更改功能即使在检查后也不会被调用

时间:2012-02-17 06:18:44

标签: c# asp.net

选择项目时,不会触发更改事件。

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 个答案:

答案 0 :(得分:1)

你有没有试过.. AutoPostBack =“true”

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