0

This is my asp.net code for dropdown: iam unable get the multiple selected ids of checkboxes.

@if (ViewBag.EventContentTypeId == Convert.ToInt32(EventContentType.Events))
{
    <div class="col-sm-3 form-group input" style="padding-left:0">
        <div class="input-group">
            @Html.DropDownList("EventCategoryDDL", @ViewBag.EventCategories as IEnumerable<SelectListItem>, new { @class = "form-control call-checkbox", @multiple = "multiple" })
            <span class="input-group-addon">
                <i class="fa fa-file-text" aria-hidden="true"></i>
            </span>
        </div>
    </div>
}

and this is my datatable code:

$('#btnSearch').click(function () {
    oTable
        .columns(12).search($("#EventCategoryDDL option:selected").val())
        .draw();
         return false;
});

here in this line

.columns(12).search($("#EventCategoryDDL option:selected").val()) 

if selected multiple checkbox ids also i am getting only one id . and iam using jquery multiselect plugin.

$('#EventCategoryDDL').multiselect({
    placeholder: '-- Select Category --',
    selectAll: true
});

and this is small multiselect code of plugin.

kumar swamy
  • 169
  • 1
  • 2
  • 13
  • Not related, but always use `ListBoxFor()`, not `DropDownListFor()` to generate a ` –  Jan 17 '18 at 11:47
  • Because `.val()` only returns the value of the first one (refer [docs](http://api.jquery.com/val/)). Use `$("#EventCategoryDDL).val()` to return an array of the selected values –  Jan 17 '18 at 11:48

0 Answers0