title: Multiselect dropdown with checkbox in mvc4 razor
body: <p>I am working on MVC4 project where i have a multi select dropdown</p>
  
  <pre><code>@Html.DropDownList("year_selected", (SelectList)(ViewData["YearSelected"]), new { tabindex = "14", multiple = "multiple", style = "width:150px;height:200px;" })
  </code></pre>
  
  <p>Its populated with list of years i have mentioned in controller</p>
  
  <pre><code>int minYear =Int32.Parse(Helper.MinYear);
  int maxYear = Int32.Parse(Helper.MaxYear);
  var yearSelectedList = new List&lt;SelectListItem&gt;();
  for (int count = minYear; count &lt;= maxYear; count++)
  {
      yearSelectedList.Add(new SelectListItem()
      {
          Text = count.ToString(),
          Value = count.ToString()
          });
      }
      var yearselectlist = new SelectList(yearSelectedList, "Value", "Text");
      ViewData["YearSelected"] = yearselectlist;
  </code></pre>
  
  <p>and on dropdown click i am calling jquery to select that particular value and also when page is loaded i checking values saved in database by making them select by default</p>
  
  <p>Here is jquery code to selected the values which are saved in database</p>
  
  <pre><code>if (str_year_selected.val() != "") {
      var yeararray = str_year_selected.val().split(",");
      for (var i in yeararray) {
           var val = yeararray[i];
           year_selected.find('option:[value=' + val + ']').attr('selected', 1);
      }
  }
  </code></pre>
  
  <p>and here is code i am using to select the value when user clicks or press ctrl key on dropdown values</p>
  
  <pre><code>year_selected.change(function () {
       var selectedyears = "";
       $("#year_selected :selected").each(function (i) {
          if (i != 0) {
              selectedyears += ",";
          }
           selectedyears += $(this).text();
       });
       str_year_selected.val(selectedyears);
  });
  </code></pre>
  
  <p>Everything is working perfect . but now problem is user wants checkbox inside of dropdown so that can check the option.</p>
  
  <p>How do i do this ?</p>