title: How to display multi-select list from List<MyObject>
body: <pre><code>class User() {
     public List&lt;Customer&gt; Customers;
  }
  
  class Customer() {
     public long Id;
     public string Name;
  }
  </code></pre>
  
  <p>I populate the selected items </p>
  
  <pre><code>User MyUser = new User(); 
  MyUser.Customers = db.Customers.Where(...).ToList();
  </code></pre>
  
  <p>I pass the list of all items in this way</p>
  
  <pre><code>ViewBag.Customers = db.Customers.OrderBy(c =&gt; c.Name).ToList();
  </code></pre>
  
  <p>In my View i want to display it like a multi-select HTML element with all (ViewBag.Customers) elements and (MyUser.Customers) as selected.
  I tried with</p>
  
  <pre><code>@model MySCL.Models.User
  
  @Html.ListBoxFor(m =&gt; m.Customers, new MultiSelectList(ViewBag.Customers, "Id", "Name"), new {Multiple = "multiple", size = "5" })
  </code></pre>
  
  <p>but it display only the complete list without select any items.
  Is this the best practice to do it?
  Is there another better way?
  Instead of a List of Customer if I had a List of string how can I do it?</p>