title: Bootstrap multiselect - Set a value as selected in the multiselect dropdown in Controller
body: <p>I am using <a href="http://davidstutz.github.io/bootstrap-multiselect/" rel="nofollow noreferrer">Bootstrap-multiselect</a> plugin to add the multiselect dropdown value with checkboxes. Its working fine and I am getting selected value also. Following is my razor code.</p>
  
  <p><code>@Html.ListBoxFor(model =&gt; model.Ex, new SelectList(ViewBag.ExList, "Value", "Text"), new { @class = "form-control", id = "excursion" })</code></p>
  
  <p>Here is my Model</p>
  
  <pre><code> public class MyModel
  {
     public List&lt;string&gt; Ex { get; set; }
  }
  
   // In here I am getting my selected values from database table.
   // This value is retrieve as comma separated string - item1,item2,item3
   var myselected_List = obj.GetSelectedList();
  
   // In here I am getting my all dropdown values from database table.
   var myall_List = obj.GetAllList();
  
  
   viewBag.ExList = myall_list.Select(x =&gt; new SelectListItem()
   {
     Text = x,
     Value = x,
  
    });
  
  // I want to combine my selected list with alllist and checked the values based on my selected list
  </code></pre>
  
  <p>I am saving the user selected drop down values in database using comma separated data. such as <code>text1, text2, text3</code>.</p>
  
  <p>In here my ViewBag.ExList contains list with values such as <code>text1, text2,text3,text4, text5</code>.</p>
  
  <p>When same user load the page second time, I want to checked the <code>text1,text2,text3</code> values as his earlier preferred value in dropdown.</p>
  
  <p>The problem here is, I can get the data from database. I have the full data list too. But I don't know how to achieve this checked checkboxes for user selected items.
  Can anybody please help me.</p>
  
  <p>Thanks</p>