Implement DropDown MultiSelect Using Kendo UI MultiSelect In ASP.NET MVC5

Introduction
 
In this article, I am going to explain how to bind the value to a dropdown from the database, how to implement drop-down multi-select, how to group the drop-down values, and how to implement Custom Template using Kendo UI MultiSelect in ASP.Net MVC5. 
 
Prerequisites 
  • Basic knowledge of MVC.
  • Basic knowledge of jQuery.
  • Basic knowledge of Entity Framework.
  • Basic knowledge of Kendo UI.
  • Basic Knowledge of CSS
Article Flow
  • Create a database table with the values
  • Create ASP.NET MVC empty Project 
  • Configure Entity Framework in ASP.Net MVC Application
  • Create Controller and Write logic to load data from database
  • Create View with Dropdown controller
  • Enable Kendo UI Multi-select features with ASP.Net MVC Application
  • Basic Feature Of Kendo UI Multi-Select
  • Kendo UI Multi-Select Grouping
  • Kendo UI Multi-Select Custom Template 
Create a database table with the values
 
First, we will create a table in SQL Server to populate the drop-down with the data in ASP.NET MVC. I have designed the below table. 

 
 
Execute the below query to create a table with the above design.
  1. CREATE TABLE [dbo].[Employee](  
  2. [Id] [int] IDENTITY(1,1) NOT NULL,  
  3. [Name] [nvarchar](200) NULL,  
  4. [Designation] [nvarchar](200) NULL,  
  5. CONSTRAINT [PK_Employee] PRIMARY KEY CLUSTERED  
  6. (  
  7.    [Id] ASC  
  8. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ONON [PRIMARY]  
  9. ON [PRIMARY]  
  10. GO  
And, insert a few dummy records. For that, execute the below query.
  1. SET IDENTITY_INSERT [dbo].[Employee] ON  
  2. GO  
  3. INSERT [dbo].[Employee] ([Id], [Name], [Designation]) VALUES (1, N'Gnanavel Sekar', N'Software Engineer')  
  4. GO  
  5. INSERT [dbo].[Employee] ([Id], [Name], [Designation]) VALUES (2, N'Ramar Ammavasi', N'Tech Lead')  
  6. GO  
  7. INSERT [dbo].[Employee] ([Id], [Name], [Designation]) VALUES (3, N'Ammaiyappan I', N'Software Engineer')  
  8. GO  
  9. INSERT [dbo].[Employee] ([Id], [Name], [Designation]) VALUES (4, N'Gokul A', N'Sr.Software Engineer')  
  10. GO  
  11. INSERT [dbo].[Employee] ([Id], [Name], [Designation]) VALUES (5, N'Karthick ', N'Sr.Software Engineer')  
  12. GO  
  13. INSERT [dbo].[Employee] ([Id], [Name], [Designation]) VALUES (6, N'Robert', N'Application Developer')  
  14. GO  
  15. INSERT [dbo].[Employee] ([Id], [Name], [Designation]) VALUES (7, N'Vinoth', N'Programmer')  
  16. GO  
  17. INSERT [dbo].[Employee] ([Id], [Name], [Designation]) VALUES (8, N'Kannan', N'Programmer')  
  18. GO  
  19. INSERT [dbo].[Employee] ([Id], [Name], [Designation]) VALUES (9, N'Gopal', N'Sr.Software Engineer')  
  20. GO  
  21. INSERT [dbo].[Employee] ([Id], [Name], [Designation]) VALUES (10, N'Ananad', N'Software Engineer')  
  22. GO  
  23. INSERT [dbo].[Employee] ([Id], [Name], [Designation]) VALUES (11, N'Manoj', N'Sr.Software Engineer')  
  24. GO  
  25. INSERT [dbo].[Employee] ([Id], [Name], [Designation]) VALUES (12, N'Subash', N'Programmer')  
  26. GO  
  27. SET IDENTITY_INSERT [dbo].[Employee] OFF  
  28. GO  
Once you execute the above query, you will get the employee record as below.
 
 
 
Create ASP.NET MVC empty project
 
To create ASP.NET MVC empty project, follow the below steps one by one. Here, I have used Visual Studio 2013. 
 
Step 1
 
Select New Project -> Visual C# -> Web -> ASP.NET Web Application and enter your application name. Here, I named it "KendoMultiSelect". Now, click OK.

Step 2
 
Select Empty MVC project and click OK to create the project. Once you click OK, the project will be created with the basic architecture of MVC.
 
 
 
Configure Entity Framework in ASP.NET MVC Application
 
In Implement Database First Approach with Entity Framework, I have already discussed how to configure and implement database first approach. In the meantime, choose your created table with Entity Framework.
 
Once we are done with our configuration with SQL table "Employee" from the CSharpCorner database, we will get the below screen as succeeding configuration. 
 
 
Create Controller and write the logic to load the data from database
 
Create an empty Controller and name it as "MultiSelectController". Whenever we create an empty Controller, it is created with empty Index action method. So, write the below logic to load the data from the database using Entity Framework.
  1. // GET: /MultiSelect/  
  2. public ActionResult Index() {  
  3.     using(CSharpCornerEntities cotext = new CSharpCornerEntities()) {  
  4.         var employeeCollection = (from employees in cotext.Employees select employees).ToList();  
  5.         if (employeeCollection != null) {  
  6.             ViewBag.Employees = employeeCollection.Select(N => new SelectListItem {  
  7.                 Text = N.Name + " - " + N.Designation, Value = N.Id.ToString()  
  8.             });  
  9.         }  
  10.     }  
  11.     return View();  
  12. }  
In the above code, you can see that we are loading employee table's data and assigning that to the viewBag. Now, right-click on this Index action method to create an empty View.
 
Create View with Dropdown Controller
 
Now, let's create a drop-down Controller in View and assign the viewBag values to it. The multiple parameters allow us to select more than one value from the drop-down.In below code, we checked whether or not the viewBag has the value. If the value is there, just simply assign the viewBag value to the drop-down.
  1. <select id="EmployeesBasic" multiple="multiple" required name="EmployeesBasic">  
  2. @if (ViewBag.Employees != null)  
  3. {  
  4.    foreach (var item in ViewBag.Employees)  
  5.    {  
  6.       if (item.Text != null)  
  7.       {  
  8.          <option value="@item.Value">  
  9.             @item.Text  
  10.          </option>  
  11.       }  
  12.    }  
  13. }  
  14. </select>  
Enable Kendo UI and Kendo UI Multi-select features with ASP.NET MVC Application
 
 Here, we going to enable the Kendo UI and Multi-Select features with our application by adding the below CSS and JS in our Layout page or View.
  1. <script src="http://code.jquery.com/jquery-1.12.4.min.js"></script>  
  2. <link href="http://cdn.rawgit.com/davidstutz/bootstrap-multiselect/master/dist/css/bootstrap-multiselect.css" rel="stylesheet" type="text/css" />  
  3. <script src="http://cdn.rawgit.com/davidstutz/bootstrap-multiselect/master/dist/js/bootstrap-multiselect.js"></script>  
  4. <link href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet" type="text/css" />  
  5. <script src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/js/bootstrap.min.js"></script>  
And, add the script given below to enable the Kendo UI Multi-select plugin to the respective control. 
  1. <script>  
  2.     $(document).ready(function() {  
  3.         // create MultiSelect from select HTML element  
  4.         //1.Basic DropDownMultiSelect  
  5.         $('#EmployeesBasic').multiselect({  
  6.             includeSelectAllOption: true  
  7.         });  
  8.     });  
  9. </script>  
We need to get the selected value from the drop-down list, so add one button in teh View and write the below script to get the selected value from drop-down.
  1. $("#btnGetBasic").click(function() {  
  2.     alert($("#EmployeesBasic").val());  
  3. });  
Run your application.
 
 
 
 
Kendo UI Multi-Select Grouping
   
In the above result, we can see that we are able to select more than one item and can view the selected item value. Now, we will see how to group the employees by departments. For that, we need to refer the below CSS and JS in our View
  1. <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.3.1026/styles/kendo.common-material.min.css" />  
  2. <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.3.1026/styles/kendo.material.min.css" />  
  3. <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.3.1026/styles/kendo.material.mobile.min.css" />  
  4. <script src="https://kendo.cdn.telerik.com/2017.3.1026/js/jquery.min.js"></script>  
  5. <script src="https://kendo.cdn.telerik.com/2017.3.1026/js/kendo.all.min.js"></script>  
Now, we will create another drop-down control like the earlier one and will load the data using jQuery AJAX and Kendo transport. Create a button to get the selected value from the drop-down list
  1. <select id="EmployeesGrouping" multiple="multiple" required name="EmployeesGrouping">  
  2. @if (ViewBag.Employees != null)  
  3. {  
  4. foreach (var item in ViewBag.Employees)  
  5. {  
  6.    if (item.Text != null)  
  7.    {  
  8.       <option value="@item.Value">  
  9.          @item.Text  
  10.       </option>  
  11.       }  
  12.    }  
  13.    }  
  14. </select> <br /> <input type="button" id="btnGetGrouping" value="Grouping - Click me to Get Selected Employee(s)" /> <br />  
Add the below script to enable kendoMultiSelect and load the data from database using kendo transport. In the below code, the dataTextField represents which column value needs to be displayed in the dropdown and the dataValueField represents value for each text and important one is group parameter to enable the grouping operation based on the column value. Here, I have mentioned to group the employees by their designation.
  1. $("#EmployeesGrouping").kendoMultiSelect({  
  2.     includeSelectAllOption: true,  
  3.     placeholder: "Select Employees...",  
  4.     dataTextField: "Name",  
  5.     dataValueField: "Id",  
  6.     height: 400,  
  7.     dataSource: {  
  8.         type: "json",  
  9.         transport: {  
  10.             read: "http://localhost:24597/MultiSelect/DropDownGrouping"  
  11.         },  
  12.         group: {  
  13.             field: "Designation"  
  14.         }  
  15.     }  
  16. });  
Write the below logic in Controller to load the data from database.
  1. public JsonResult DropDownGrouping()  
  2. {  
  3.    CSharpCornerEntities cotext = new CSharpCornerEntities();  
  4.    var employeeCollection = (from employees in cotext.Employees select employees).ToList();  
  5.    return Json(employeeCollection, JsonRequestBehavior.AllowGet);  
  6. }  
And, add the below event to get the selected value from drop-down list
  1. $("#btnGetGrouping").click(function () {  
  2.    alert($("#EmployeesGrouping").val());  
  3. });  
Run your application.
 
  
 
Kendo UI Multi-Select Custom Template
 
Here, we will build a custom template to view the employee photo in drop-down list. For that, use the same CSS and JS whatever we used for grouping functionality.
  1. <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.3.1026/styles/kendo.common-material.min.css" />  
  2. <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.3.1026/styles/kendo.material.min.css" />  
  3. <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.3.1026/styles/kendo.material.mobile.min.css" />  
  4. <script src="https://kendo.cdn.telerik.com/2017.3.1026/js/jquery.min.js"></script>  
  5. <script src="https://kendo.cdn.telerik.com/2017.3.1026/js/kendo.all.min.js"></script>  
And, create a drop-down Controller with one button in a View.
  1. <div id="example">  
  2.     <div class="demo-section k-content"> <select id="EmployeesCustom" style="width: 100%;"></select>  
  3.         <p class="demo-hint"> Click to see the customized appearance. </p>  
  4.     </div>  
  5. </div> <br /> <input type="button" id="btnGetCustom" value="Custom Template - Click me to Get Selected Employee(s)" />  
And, create a template in the script using KendoMultiSelect as below.
  1. $("#EmployeesCustom").kendoMultiSelect({  
  2.     dataTextField: "Name",  
  3.     dataValueField: "Id",  
  4.     headerTemplate: '<div class="dropdown-header k-widget k-header">' + '<span>Photo</span>' + '<span>Employee Info</span>' + '</div>',  
  5.     footerTemplate: 'Total #: instance.dataSource.total() # items found',  
  6.     itemTemplate: '<span class="k-state-default" style="background-image: url(\'../Content/Employees/#:data.Id#.jpg\')"></span>' + '<span class="k-state-default"><h3>#: data.Name #</h3><p>#: data.Designation #</p></span>',  
  7.     tagTemplate: '<span class="selected-value" style="background-image: url(\'../Content/Employees/#:data.Id#.jpg\')"></span><span>#:data.Name#</span>',  
  8.     dataSource: {  
  9.         transport: {  
  10.             read: {  
  11.                 dataType: "json",  
  12.                 url: "http://localhost:24597/MultiSelect/DropDownGrouping",  
  13.             }  
  14.         }  
  15.     },  
  16.     height: 400  
  17. });  
Detailed Description 
  • $("#EmployeesCustom").kendoMultiSelect({ -> To enable multi-select dropdown.
  • dataTextField: "Name", -> Which field needs to be displayed
  • dataValueField: "Id", -> Which field needs to be a value fields 
  • headerTemplate -> To create a tiltile over the drop-down list, here, we mentioned to create two titles such as photo and employee info 
  • footerTemplate-> Will be displayed bottom of the dropdownlist and here, we used the footer template to display the counts of employee
  • itemTemplate-> It will the data from database, in kendo template, we should specify our desire column value to display and it should be mentioned like #:data.Name# and we load the data from database using the transport read.
Add the below button click event to get the selected drop-down list value.
  1. $("#btnGetCustom").click(function () {  
  2.    alert($("#EmployeesCustom").val());  
  3. });  
Write the below logic in a Controller to load the data from the database. This action method is called from kendo transport read.
  1. public JsonResult DropDownGrouping() {  
  2.     CSharpCornerEntities cotext = new CSharpCornerEntities();  
  3.     var employeeCollection = (from employees in cotext.Employees select employees).ToList();  
  4.     return Json(employeeCollection, JsonRequestBehavior.AllowGet);  
  5. }  
Add the below CSS to give good appearance to your drop-down custom template.
  1. <style>  
  2.     .dropdown-header {  
  3.         border-width: 0 0 1px 0;  
  4.         text-transform: uppercase;  
  5.     }  
  6.   
  7.     .dropdown-header>span {  
  8.         display: inline-block;  
  9.         padding: 10px;  
  10.     }  
  11.   
  12.     .dropdown-header>span:first-child {  
  13.         width: 50px;  
  14.     }  
  15.   
  16.     .k-list-container>.k-footer {  
  17.         padding: 10px;  
  18.     }  
  19.   
  20.     .selected-value {  
  21.         display: inline-block;  
  22.         vertical-align: middle;  
  23.         width: 18px;  
  24.         height: 18px;  
  25.         background-size: 100%;  
  26.         margin-right: 5px;  
  27.         border-radius: 50%;  
  28.     }  
  29.  
  30.     #EmployeesCustom-list .k-item {  
  31.         line-height: 1em;  
  32.         min-width: 300px;  
  33.     }  
  34.   
  35.     /* Material Theme padding adjustment*/  
  36.   
  37.     .k-material #EmployeesCustom-list .k-item,  
  38.     .k-material #custoEmployeesCustommers-list .k-item.k-state-hover,  
  39.     .k-materialblack #EmployeesCustom-list .k-item,  
  40.     .k-materialblack #EmployeesCustom-list .k-item.k-state-hover {  
  41.         padding-left: 5px;  
  42.         border-left: 0;  
  43.     }  
  44.  
  45.     #EmployeesCustom-list .k-item>span {  
  46.         -webkit-box-sizing: border-box;  
  47.         -moz-box-sizing: border-box;  
  48.         box-sizing: border-box;  
  49.         display: inline-block;  
  50.         vertical-align: top;  
  51.         margin: 20px 10px 10px 5px;  
  52.     }  
  53.  
  54.     #EmployeesCustom-list .k-item>span:first-child {  
  55.         -moz-box-shadow: inset 0 0 30px rgba(0, 0, 0, .3);  
  56.         -webkit-box-shadow: inset 0 0 30px rgba(0, 0, 0, .3);  
  57.         box-shadow: inset 0 0 30px rgba(0, 0, 0, .3);  
  58.         margin: 10px;  
  59.         width: 50px;  
  60.         height: 50px;  
  61.         border-radius: 50%;  
  62.         background-size: 100%;  
  63.         background-repeat: no-repeat;  
  64.     }  
  65.  
  66.     #EmployeesCustom-list h3 {  
  67.         font-size: 1.2em;  
  68.         font-weight: normal;  
  69.         margin: 0 0 1px 0;  
  70.         padding: 0;  
  71.     }  
  72.  
  73.     #EmployeesCustom-list p {  
  74.         margin: 0;  
  75.         padding: 0;  
  76.         font-size: .8em;  
  77.     }  
  78. </style>  
Now, run your application.
 
 
 
Complete View 
  1. @ {  
  2.     ViewBag.Title = "Index";  
  3. } < title > < /title>  
  4. @ * Basic DropDownMultiSelect CSS and JS Start * @ < script src = "http://code.jquery.com/jquery-1.12.4.min.js" > < /script> < link href = "http://cdn.rawgit.com/davidstutz/bootstrap-multiselect/master/dist/css/bootstrap-multiselect.css"  
  5. rel = "stylesheet"  
  6. type = "text/css" / > < script src = "http://cdn.rawgit.com/davidstutz/bootstrap-multiselect/master/dist/js/bootstrap-multiselect.js" > < /script> < link href = "http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css"  
  7. rel = "stylesheet"  
  8. type = "text/css" / > < script src = "http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/js/bootstrap.min.js" > < /script>  
  9. @ * Basic DropDownMultiSelect CSS and JS End * @  
  10. @ * //Grouping and Custom Template Related CSS and JS Start *@  
  11.     < link rel = "stylesheet"  
  12. href = "https://kendo.cdn.telerik.com/2017.3.1026/styles/kendo.common-material.min.css" / > < link rel = "stylesheet"  
  13. href = "https://kendo.cdn.telerik.com/2017.3.1026/styles/kendo.material.min.css" / > < link rel = "stylesheet"  
  14. href = "https://kendo.cdn.telerik.com/2017.3.1026/styles/kendo.material.mobile.min.css" / > < script src = "https://kendo.cdn.telerik.com/2017.3.1026/js/jquery.min.js" > < /script> < script src = "https://kendo.cdn.telerik.com/2017.3.1026/js/kendo.all.min.js" > < /script>  
  15. @ * //Grouping Related CSS and JS End *@  
  16.     < body > < br / > < div > @ * Basic Template Start * @ < select id = "EmployeesBasic"  
  17. multiple = "multiple"  
  18. required name = "EmployeesBasic" > @if(ViewBag.Employees != null) {  
  19.     foreach(var item in ViewBag.Employees) {  
  20.         if (item.Text != null) { < option value = "@item.Value" > @item.Text < /option>  
  21.         }  
  22.     }  
  23. } < /select> < br / > < br / > < input type = "button"  
  24. id = "btnGetBasic"  
  25. value = "Basic - to Get Selected Employee(s)" / > < br / > @ * Basic Template End * @  
  26. @ * Grouping Template Start * @ < select id = "EmployeesGrouping"  
  27. multiple = "multiple"  
  28. required name = "EmployeesGrouping" > @if(ViewBag.Employees != null) {  
  29.     foreach(var item in ViewBag.Employees) {  
  30.         if (item.Text != null) { < option value = "@item.Value" > @item.Text < /option>  
  31.         }  
  32.     }  
  33. } < /select> < br / > < input type = "button"  
  34. id = "btnGetGrouping"  
  35. value = "Grouping - Click me to Get Selected Employee(s)" / > < br / > @ * Grouping Template End * @  
  36. @ * Custom Template Start * @ < div id = "example" > < div class = "demo-section k-content" > < select id = "EmployeesCustom"  
  37. style = "width: 100%;" > < /select> < p class = "demo-hint" > Click to see the customized appearance. < /p> < /div> < /div> < br / > < input type = "button"  
  38. id = "btnGetCustom"  
  39. value = "Custom Template - Click me to Get Selected Employee(s)" / > @ * Custom Template End * @ < br / > < script > $(document).ready(function() {  
  40.     // create MultiSelect from select HTML element  
  41.     //1.Basic DropDownMultiSelect  
  42.     $('#EmployeesBasic').multiselect({  
  43.         includeSelectAllOption: true  
  44.     });  
  45.     //2.Grouping Dropdown Multi Select  
  46.     $("#EmployeesGrouping").kendoMultiSelect({  
  47.         includeSelectAllOption: true,  
  48.         placeholder: "Select Employees...",  
  49.         dataTextField: "Name",  
  50.         dataValueField: "Id",  
  51.         height: 400,  
  52.         dataSource: {  
  53.             type: "json",  
  54.             transport: {  
  55.                 read: "http://localhost:24597/MultiSelect/DropDownGrouping"  
  56.             },  
  57.             group: {  
  58.                 field: "Designation"  
  59.             }  
  60.         }  
  61.     });  
  62.     //Custom DropDown Template  
  63.     $("#EmployeesCustom").kendoMultiSelect({  
  64.         dataTextField: "Name",  
  65.         dataValueField: "Id",  
  66.         headerTemplate: '<div class="dropdown-header k-widget k-header">' + '<span>Photo</span>' + '<span>Employee Info</span>' + '</div>',  
  67.         footerTemplate: 'Total #: instance.dataSource.total() # items found',  
  68.         itemTemplate: '<span class="k-state-default" style="background-image: url(\'../Content/Employees/#:data.Id#.jpg\')"></span>' + '<span class="k-state-default"><h3>#: data.Name #</h3><p>#: data.Designation #</p></span>',  
  69.         tagTemplate: '<span class="selected-value" style="background-image: url(\'../Content/Employees/#:data.Id#.jpg\')"></span><span>#:data.Name#</span>',  
  70.         dataSource: {  
  71.             transport: {  
  72.                 read: {  
  73.                     dataType: "json",  
  74.                     url: "http://localhost:24597/MultiSelect/DropDownGrouping",  
  75.                 }  
  76.             }  
  77.         },  
  78.         height: 400  
  79.     });  
  80.     //Basic  
  81.     $("#btnGetBasic").click(function() {  
  82.         alert($("#EmployeesBasic").val());  
  83.     });  
  84.     //Grouping  
  85.     $("#btnGetGrouping").click(function() {  
  86.         alert($("#EmployeesGrouping").val());  
  87.     });  
  88.     //Custom  
  89.     $("#btnGetCustom").click(function() {  
  90.         alert($("#EmployeesCustom").val());  
  91.     });  
  92. }); < /script>  
  93. @ * Custom Template Related CSS * @ < style > .dropdown - header {  
  94.     border - width: 0 0 1 px 0;  
  95.     text - transform: uppercase;  
  96. }.dropdown - header > span {  
  97.     display: inline - block;  
  98.     padding: 10 px;  
  99. }.dropdown - header > span: first - child {  
  100.     width: 50 px;  
  101. }.k - list - container > .k - footer {  
  102.     padding: 10 px;  
  103. }.selected - value {  
  104.     display: inline - block;  
  105.     vertical - align: middle;  
  106.     width: 18 px;  
  107.     height: 18 px;  
  108.     background - size: 100 % ;  
  109.     margin - right: 5 px;  
  110.     border - radius: 50 % ;  
  111. }#  
  112. EmployeesCustom - list.k - item {  
  113.         line - height: 1e m;  
  114.         min - width: 300 px;  
  115.     }  
  116.     /* Material Theme padding adjustment*/  
  117.     .k - material# EmployeesCustom - list.k - item, .k - material# custoEmployeesCustommers - list.k - item.k - state - hover, .k - materialblack# EmployeesCustom - list.k - item, .k - materialblack# EmployeesCustom - list.k - item.k - state - hover {  
  118.         padding - left: 5 px;  
  119.         border - left: 0;  
  120.     }#  
  121. EmployeesCustom - list.k - item > span {  
  122.     -webkit - box - sizing: border - box; - moz - box - sizing: border - box;  
  123.     box - sizing: border - box;  
  124.     display: inline - block;  
  125.     vertical - align: top;  
  126.     margin: 20 px 10 px 10 px 5 px;  
  127. }#  
  128. EmployeesCustom - list.k - item > span: first - child {  
  129.     -moz - box - shadow: inset 0 0 30 px rgba(0, 0, 0, .3); - webkit - box - shadow: inset 0 0 30 px rgba(0, 0, 0, .3);  
  130.     box - shadow: inset 0 0 30 px rgba(0, 0, 0, .3);  
  131.     margin: 10 px;  
  132.     width: 50 px;  
  133.     height: 50 px;  
  134.     border - radius: 50 % ;  
  135.     background - size: 100 % ;  
  136.     background - repeat: no - repeat;  
  137. }#  
  138. EmployeesCustom - list h3 {  
  139.     font - size: 1.2e m;  
  140.     font - weight: normal;  
  141.     margin: 0 0 1 px 0;  
  142.     padding: 0;  
  143. }#  
  144. EmployeesCustom - list p {  
  145.     margin: 0;  
  146.     padding: 0;  
  147.     font - size: .8e m;  
  148. } < /style> < /div> < /body>  
Complete Controller 
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Web;  
  5. using System.Web.Mvc;  
  6. using KendoMultiSelect.Models;  
  7. namespace KendoMultiSelect.Controllers {  
  8.     public class MultiSelectController: Controller {  
  9.         //  
  10.         // GET: /MultiSelect/  
  11.         public ActionResult Index() {  
  12.             using(CSharpCornerEntities cotext = new CSharpCornerEntities()) {  
  13.                 var employeeCollection = (from employees in cotext.Employees select employees).ToList();  
  14.                 if (employeeCollection != null) {  
  15.                     ViewBag.Employees = employeeCollection.Select(N => new SelectListItem {  
  16.                         Text = N.Name + " - " + N.Designation, Value = N.Id.ToString()  
  17.                     });  
  18.                 }  
  19.             }  
  20.             return View();  
  21.         }  
  22.         public JsonResult DropDownGrouping() {  
  23.             CSharpCornerEntities cotext = new CSharpCornerEntities();  
  24.             var employeeCollection = (from employees in cotext.Employees select employees).ToList();  
  25.             return Json(employeeCollection, JsonRequestBehavior.AllowGet);  
  26.         }  
  27.     }  
  28. }  
RouteConfig 
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Web;  
  5. using System.Web.Mvc;  
  6. using System.Web.Routing;  
  7. namespace KendoMultiSelect {  
  8.     public class RouteConfig {  
  9.         public static void RegisterRoutes(RouteCollection routes) {  
  10.             routes.IgnoreRoute("{resource}.axd/{*pathInfo}");  
  11.             routes.MapRoute(name: "Default", url: "{controller}/{action}/{id}", defaults: new {  
  12.                 controller = "MultiSelect", action = "Index", id = UrlParameter.Optional  
  13.             });  
  14.         }  
  15.     }  
  16. }  
I hope you got a clear picture of Kendo UI Multi-Select features. I did attach the demonstrated project without package for Entity Framework 6.0 due to the size limit.
 
Summary 
 
In this article, you learned how to work with Kendo UI MultiSelect in ASP.NET MVC application, how to bind the data to it, how to group the drop-down items, how to create a custom template, and how to get the selected data from the drop-down.
 
I hope it's helpful. Your valuable feedback and comments about this article are always welcome. 

Up Next
    Ebook Download
    View all
    Learn
    View all