title: ASP MVC Model List<object> Returned Empty in POST action
body: <p>I have got this problem that I am having a difficulty to solve. I am creating a page where the user will be presented with a list of items (Product Types). Each item will have a dropdown list next to it so that the user can make appropriate selection to create a mapping. After making selection then the user submits the form, and the value will be written to the database.</p>
  
  <p>The problem is that when it is submitted, I am not getting any values back. Specifically, 'Mappings' is empty in the model that is returned by the POST action. The GET action works fine. The following is the essence of what I have written:</p>
  
  <p>Model:</p>
  
  <pre><code>public class ProductTypeMappingViewModel
  {
      //this is empty in the POST object
      public List&lt;ProductTypeMapping&gt; Mappings { get; set; }
  
      public ProductTypeMappingViewModel()
      {
          Mappings = new List&lt;ProductTypeMapping&gt;();
      }
  
      public ProductTypeMappingViewModel(string db)
      {
          //use this to populate 'Mappings' for GET action
          //works fine
      }
  
      public void UpdateDB()
      {
          //to be called on the object
          //returned from POST action
          foreach(var mapping in Mappings)
          {
          //Mappings is always empty after POST
          //Suppose to add to db
          }
      }
  }
  
  public class ProductTypeMapping
  {
      public string ProductTypeName { get; set; }
      public int SelectedStandardProductTypeKey { get; set; }
      public SelectList StandardProductTypes { get; set; }
  
      public ProductTypeMapping() 
      {
          StandardProductTypes = new SelectList(new List&lt;SelectListItem&gt;());
      }
  
      public int GetSelectedProductTypeKey() { //return selected key}
  
      public string GetSelectedProductTypeName() { //return selected name} 
  }
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>@model CorporateM10.Models.ProductTypeMappingViewModel
  
  @using (Html.BeginForm())
  {
      @Html.AntiForgeryToken()
  
      &lt;div class="form-horizontal"&gt;
  
          @Html.ValidationSummary(true)
  
          &lt;table class="table"&gt;
              @foreach (var dept in Model.Mappings)
              {
              &lt;tr&gt;
                  &lt;td&gt;
                      @Html.DisplayFor(model =&gt; dept.ProductTypeName, new { })
                  &lt;/td&gt;
                  &lt;td&gt;
                      @Html.DropDownListFor(model =&gt; dept.SelectedStandardProductTypeKey, dept.StandardProductTypes, "(Select Department)", new { })
                  &lt;/td&gt;
              &lt;/tr&gt;
              }
          &lt;/table&gt;
  
          &lt;div&gt;
              &lt;input type="submit" value="Save" class="btn btn-default" /&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  }
  </code></pre>
  
  <p>Any insight will be greatly appreciated.</p>