In this article, I will explain how to implement a Multiple Select (MultiSelect) DropDownList with CheckBoxes in ASP.NET with jQuery Bootstrap Multi-Select Plugin.
To actualize a Multiple Select (MultiSelect) DropDownList with CheckBoxes in ASP.NET, we should make use of ListBox control and apply jQuery Bootstrap Multi-Select Plugin to it.
To actualize a Multiple Select (MultiSelect) DropDownList with CheckBoxes in ASP.NET, we should make use of ListBox control and apply jQuery Bootstrap Multi-Select Plugin to it.
If you are a beginner in ASP.NET MVC and jQuery, I am listing some important links to learn-
You can follow the simple steps, given below, to implement a Multiple Select DropdownList with CheckBox. I am creating a MVC Application and creating controller "Home".
In the next step, create an Action to open the view "Index". See the example, given below-
In the next step, create an Action to open the view "Index". See the example, given below-
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- namespace DropdownCheckbox.Controllers
- {
- public class HomeController : Controller
- {
- public ActionResult Index()
- {
- return View();
- }
- }
- }
Create view name as "Index.cshtml". See the example, given below-
- @{
- ViewBag.Title = "Home Page";
- Layout = null;
- }
- <div>
- <table>
- <tr>
- <td><p >Select Expert's Name </p></td>
- <td>
- <select id="EmpList" multiple="multiple">
- <option value="1">Navdeep-Asp.net</option>
- <option value="2">Pankaj-C#</option>
- <option value="3">Bikesh-Asp.Net</option>
- <option value="4">Pritam-Salesforce</option>
- <option value="5">Payal-Salesforce</option>
- <option value="6">Sujata-SSRS</option>
- <option value="7">Harikant-UI</option>
- </select>
- </td>
- <td><input type="button" id="btnSelected" value="Get Selected" /></td>
- </tr>
- </table>
- </div>
In this article, I am using hard code value, but you can bind from the database. Afterwards, add jQuery Plugins or CDN, as shown below-
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
- <link href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css"
- rel="stylesheet" type="text/css" />
- <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/js/bootstrap.min.js"></script>
- <link href="http://cdn.rawgit.com/davidstutz/bootstrap-multiselect/master/dist/css/bootstrap-multiselect.css"
- rel="stylesheet" type="text/css" />
- <script src="http://cdn.rawgit.com/davidstutz/bootstrap-multiselect/master/dist/js/bootstrap-multiselect.js"
- type="text/javascript"></script>
Use the references in your Application.
Afterwards, write JS code to implement multiselect with Checkbox in Dropdown. Use the code, given below-
Afterwards, write JS code to implement multiselect with Checkbox in Dropdown. Use the code, given below-
- <script type="text/javascript">
- $(function () {
- $('#EmpList').multiselect({
- includeSelectAllOption: true
- });
- $('#btnSelected').click(function () {
- var selected = $("#EmpList option:selected");
- var message = "";
- selected.each(function () {
- message += $(this).text() + " " + $(this).val() + "\n";
- });
- alert(message);
- });
- });
- </script>
Set routing inside "route.config" file. See the code, given below-
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using System.Web.Routing;
- namespace DropdownCheckbox
- {
- public class RouteConfig
- {
- public static void RegisterRoutes(RouteCollection routes)
- {
- routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
- routes.MapRoute(
- name: "Default",
- url: "{controller}/{action}/{id}",
- defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
- );
- }
- }
- }
Complete code
You can see and understand the complete code, given below-
- @{
- ViewBag.Title = "Home Page";
- Layout = null;
- }
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
- <link href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css"
- rel="stylesheet" type="text/css" />
- <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/js/bootstrap.min.js"></script>
- <link href="http://cdn.rawgit.com/davidstutz/bootstrap-multiselect/master/dist/css/bootstrap-multiselect.css"
- rel="stylesheet" type="text/css" />
- <script src="http://cdn.rawgit.com/davidstutz/bootstrap-multiselect/master/dist/js/bootstrap-multiselect.js"
- type="text/javascript"></script>
- <script type="text/javascript">
- $(function () {
- $('#EmpList').multiselect({
- includeSelectAllOption: true
- });
- $('#btnSelected').click(function () {
- var selected = $("#EmpList option:selected");
- var message = "";
- selected.each(function () {
- message += $(this).text() + " " + $(this).val() + "\n";
- });
- alert(message);
- });
- });
- </script>
- <div>
- <table>
- <tr>
- <td><p >Select Expert's Name </p></td>
- <td>
- <select id="EmpList" multiple="multiple">
- <option value="1">Navdeep-Asp.net</option>
- <option value="2">Pankaj-C#</option>
- <option value="3">Bikesh-Asp.Net</option>
- <option value="4">Pritam-Salesforce</option>
- <option value="5">Payal-Salesforce</option>
- <option value="6">Sujata-SSRS</option>
- <option value="7">Harikant-UI</option>
- </select>
- </td>
- <td><input type="button" id="btnSelected" value="Get Selected" /></td>
- </tr>
- </table>
- </div>

According to the example, I can select any one or multiple choices. Also, you can see the count of the selected items.
We can see the item on the popup after clicking on "GetSelected".
I hope, you enjoyed this article and learned lots of things. If you have any confusion regarding these topics, you can download the project.

Naqi ZaidiPosted Dec 9, 2019, 11:19 AM
Thanks for sharing useful information. but edit functionality code not work please help me to edit functionality
Aditya SononePosted Sep 20, 2019, 5:14 AM
I have used this and it works when I am using individual drop downs but I need concatenated dropdowns (country, state,city). so when i change the OPTIONS of STATE's SELECT through jquery on change of COUNTRY, STATE dropdown does not work. Can you help how it can be done
HolmPosted Jul 17, 2019, 2:40 AM
I've done this example to the letter and many other multiselect examples but all of them yield the same result. I only ever get a select box with options. Never a dropdown with checkboxes inside. What can I be doing wrong? I use MVC5 and .Net 4.8. I've tried to change .Net to 4.6 but that didnt do anything...
Ketan AgnihotriPosted Jul 15, 2019, 5:13 AM
Can you please tell how it will work in edit view ?
Arun Kumaar MallesanPosted Oct 18, 2018, 9:44 PM
Hi, I would like to load the the collection from DB with "Selected" true for few options. But it seems not to be working with /cdn.rawgit.com/davidstutz/bootstrap-multiselect/master/dist/js/bootstrap-multiselect.js". Do you have any idea on that_?
Shushant TyagiPosted Oct 15, 2018, 8:35 AM
How to set selected items?
Farhan AhmedPosted Jul 24, 2018, 5:01 AM
Just wow............
sudheer samudralaPosted Apr 10, 2018, 4:02 AM
How can we do the unselect in jquery on certain action? on dropdown change i want to clear the other multiselect values to clear??
Parmar VirendraPosted Jan 3, 2018, 3:27 AM
Thanks for sharing useful information.
RahulPosted Dec 29, 2017, 5:07 AM
In my case, Radio buttons getting rendered inside dropdown instead of the checkboxes. I have included same two libraries one CSS and another one JS. and inside the document ready, i am calling multiselect method with dropdown id. Any help?
Sujit JhaPosted Oct 18, 2017, 1:43 PM
It is great article. But it is messing my other css as well. Please suggest how to apply those css in only this control .
Sandip KumarPosted Sep 29, 2017, 3:01 AM
Hello, Bikesh Srivastava how to merge or combine two dropdownlist value in one in a view page.
Ravi Polara PatidarPosted Sep 1, 2017, 8:03 AM
Hello, Bikesh Srivastava How to Reverse Set Value in multiselect.
Hari mcaPosted Jun 7, 2017, 2:59 AM
I am not able to bind values dynamically using angular JS for this drop down. Could you please suggest?
Prasanna MuraliPosted Oct 9, 2016, 10:14 AM
Nice post..
Bikesh SrivastavaPosted Oct 5, 2016, 10:17 AM
Thanks to all
Manav PandyaPosted Oct 5, 2016, 10:06 AM
Great post sir ..
Vignesh ManiPosted Oct 5, 2016, 4:45 AM
Good One Bikesh
Madhanmohan DevarajanPosted Oct 4, 2016, 12:32 PM
Thanks for sharing useful information.