Drop-Down-Check-Boxes select un-select malfunction

871 Views Asked by At

I Have a 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>

and SelectedIndexChanged event for it

 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)
            {

            }

        }

when I open the dropdowncheckbox and click "Select all" it selects all and when I uncheck Select all it unchecks all but when I want to check Select all again, it does not check all the options

thanks for the help

1

There are 1 best solutions below

0
On BEST ANSWER

I just solved it

in case someone has the same problem

in aspx part AddJQueryReference should be 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>