title: post viewmodel with IList to controller post method
body: <p>I have a view model with a IList:</p>
  
  <pre><code>public class MyMaintenanceListViewModel
  {
      public IList&lt;MyMaintenance&gt; MyMaintenanceList { get; set; }
  
      [Display(Name = "Network User Name:")]
      public string NetworkUserName { get; set; }
  
      [Display(Name = "Password:")]
      public string Password { get; set; }
  }
  </code></pre>
  
  <p>I have a view whose model is set to the viewmodel:</p>
  
  <pre><code>@model EMMS.ViewModels.MyMaintenanceListViewModel
  
  @using (Html.BeginForm("SubmitMaintenance", "Maintenance"))
  {
      &lt;table id="searchtable" class="MyMaintenance"&gt;
          &lt;tr&gt;
              &lt;th style="width: 50px; text-align: left;"&gt;Id&lt;/th&gt;
              &lt;th style="width: 200px; text-align: left;"&gt;Equipment Id&lt;/th&gt;
              &lt;th style="width: 100px; text-align: left;"&gt;Task Id&lt;/th&gt;
              &lt;th style="width: 150px; text-align: left;"&gt;Date Completed&lt;/th&gt;
              &lt;th style="width: 100px; text-align: left;"&gt;Elapsed Time&lt;/th&gt;
              &lt;th style="width: 200px; text-align: left;"&gt;Created&lt;/th&gt;
              &lt;th style="width: 50px;"&gt;&lt;/th&gt;
          &lt;/tr&gt;
      @for (int i = 0; i &lt; Model.MyMaintenanceList.Count; i++)
      {
          var item = Model.MyMaintenanceList[i];
         &lt;tr&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.RowId)
                  @Html.HiddenFor(modelItem =&gt; item.RowId)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.EquipmentId)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.TaskId)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.DateCompleted)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.ElapsedTimeMinutes)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.CreateDate)
              &lt;/td&gt;
          &lt;/tr&gt;
      }
      &lt;/table&gt;
  }
  </code></pre>
  
  <p>My controller looks something like this:</p>
  
  <pre><code>[HttpPost]
  public ActionResult SubmitMaintenance(MyMaintenanceListViewModel myMaintenanceListViewModel)
  {
      // do something with IList "MyMaintenanceList" in myMaintenanceListViewModel
  }
  </code></pre>
  
  <p>However, when I breakpoint the controller post method above and submit the form, the MyMaintenanceList list in myMaintenanceListViewModel says count=0, even though there are items in the view. How can I pass the items in this table to a post method in my controller?</p>
  
  <p>I am trying to iterate over the items in the MyMaintenanceList list in the controller. Hope this makes sense.</p>
  
  <p>Thanks</p>