Select query to fetch multiple checkbox items

  • Hi,

    I have a dropdown list with checkbox and when I select multiple options and search, its returning only the last selected value in the grid. Here is the code I use it for search. Designation is the column where I bind its values to the checkbox.

    Any suggestions or change in the select query?

    Checkbox tag:

    <asp:CheckBoxList ID="cblGroup" Style="vertical-align: baseline" runat="server" CssClass="chkbox">

    </asp:CheckBoxList>

    Select Query:

    SqlCommand cmd = new SqlCommand("select * from AppInvent_Test where Designation= '" + cblGroup.SelectedValue + "'", con);

  • I think you need to go trough items in list and check selected for each one of them. Generate SQL from that and use in (selected items separated with comma) instead of =.

    See http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listcontrol.items(v=vs.110).aspx

  • Got it!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply