下拉复选框选择不选择故障

本文关键字:选择 故障 复选框 | 更新日期: 2023-09-27 17:54:33

我有一个DropDownCheckBoxes

<asp:DropDownCheckBoxes CssClass="FreeTextFilterSelection" ID="cbMarket" AddJQueryReference="false" UseSelectAllNode="True" 
     AutoPostBack="true" DataTextField="Text" runat="server" OnSelectedIndexChanged="cbMarket_SelectedIndexChanged" style="height: 19px" >
     <Texts SelectBoxCaption="" />  
</asp:DropDownCheckBoxes>

和SelectedIndexChanged事件

 protected void cbMarket_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string s = string.Empty;
                string s1 = string.Empty;
                int i = 0;
                foreach (ListItem item in (sender as DropDownCheckBoxes).Items)
                {
                    if (item.Selected)
                    {
                        if (i > 0)
                        {
                            s = s + " ...";
                            break;
                        }
                        else
                        {
                            s1 = item.Text;
                            if (string.IsNullOrEmpty(s1))
                                s1 = "NULL";
                            s = s + s1;
                        }
                        i++;
                    }
                }
                (sender as DropDownCheckBoxes).Texts.SelectBoxCaption = s;
            }
            catch (Exception)
            {
            }
        }

当我打开下拉复选框并单击"Select all"时,它选中所有,当我取消选中Select all时,它取消选中所有,但当我想再次选中Select all时,它不选中所有选项

thanks for the help

下拉复选框选择不选择故障

我刚解决了

以防有人有同样的问题

aspx部分AddJQueryReference中的

应为true

<asp:DropDownCheckBoxes CssClass="FreeTextFilterSelection" ID="cbMarket" AddJQueryReference="true" UseSelectAllNode="True"
AutoPostBack="true" DataTextField="Text" runat="server" OnSelectedIndexChanged="cbMarket_SelectedIndexChanged" style="height: 19px" >
<Texts SelectBoxCaption="" />
</asp:DropDownCheckBoxes>