title: MVC Model Binding IList<T> data to Html.Listbox
body: <p>I want to bind my Store class which has multiple Products to Html.Listbox. 
  While in edit Store mode, I want Html.Listbox show all products where products of the Store are selected. I could not manage to bind store.Products to the listbox</p>
  
  <p>My class structure;</p>
  
  <pre><code>public class Store
  {
     public virtual int Id { get; set; }  
     public virtual string Name { get; set; }       
     public virtual IList&lt;Product&gt; Products { get; set; }
  }
  public class Product
  {
     public virtual int Id { get; set; }  
     public virtual string Name { get; set; }       
  }
  public class StoreEditView
  {
     public virtual int Id { get; set; }  
     public virtual string Name { get; set; }       
     public virtual IList&lt;Product&gt; Products { get; set; }
     public virtual MultiSelectList ProductList //populated from db, all products in the form of IList&lt;Product&gt;
  }
  </code></pre>
  
  <p>My controller;</p>
  
  <pre><code>  public ViewResult Edit()
    {
      var editstore = new StoreEditView();
      editstore.Products = new List&lt;Product&gt; {new Product() {Id = 1, Name="Example"}};
      return View(editstore);
    }
  </code></pre>
  
  <p>My View;</p>
  
  <pre><code> &lt;%=Html.ListBox("Products", Model.ProductList)%&gt;
  </code></pre>
  
  <p>In this case, I need product.Id=1 to be shown selected in the listbox. So far I couldn't do it.
  I tried,</p>
  
  <pre><code>&lt;%=Html.ListBox("Product.Id", Model.ProductList)%&gt;
  &lt;%=Html.ListBox("Products.Id", Model.ProductList)%&gt;
  </code></pre>
  
  <p>just didn't work.</p>