title: MVC5 ViewModel Not Posting back to Controller
body: <p>So, I have an issue with a controller/view/viewmodel.  It's similar to <a href="https://stackoverflow.com/questions/18299669/mvc-4-viewmodel-not-being-sent-back-to-controller">this issue</a> I think.  Basically, I have a viewmodel that I send to a view from my controller.  There are items that display and then some additional fields for the user to manipulate before the whole mess is sent back over to a controller post action.  When I get the data back in my post, all of the viewmodel is empty.</p>
  
  <p>So, without further ado, here's some code to look at:</p>
  
  <p><strong>ViewModel:</strong></p>
  
  <pre><code>public class ASideReceivingViewModel
  {
      public PurchaseOrderLine poLine;
      public ReceivingItem receivingItem;
  
      public Dictionary&lt;string, string&gt; TankerOrRailcarOptions { get; set; }
  
      public ASideReceivingViewModel()
      {
          TankerOrRailcarOptions = new Dictionary&lt;string, string&gt;();
          TankerOrRailcarOptions.Add("R", "Railcar");
          TankerOrRailcarOptions.Add("T", "Tanker");
  
      }
  
  }
  </code></pre>
  
  <p><strong>Controller Actions:</strong>        </p>
  
  <pre><code>public ActionResult Receive(string strOrdNo, short? shtLineNo)
  {
  
      //if there isn't a selected po line, then shoot them back to the first page
      if (strOrdNo == null || !shtLineNo.HasValue) return RedirectToAction("Index");
  
      PurchaseOrderService poService = new PurchaseOrderService();
      ReceivingItemService s = new ReceivingItemService(p);
  
      ASideReceivingViewModel vm = new ASideReceivingViewModel();
  
  
      vm.poLine = poService.GetOpenPurchaseOrderLines().Where(po =&gt; po.Ord_no == strOrdNo &amp;&amp;
          po.Line_no == shtLineNo).FirstOrDefault();
  
      if (vm.poLine == null) return RedirectToAction("Index");
  
      vm.receivingItem = s.CreateNewReceivingItem(vm.poLine);
  
      return View(vm);
  
  }
  
  [HttpPost]
  [ValidateAntiForgeryToken]
  public ActionResult Receive(ASideReceivingViewModel mytestvm)
  {
      if (ModelState.IsValid &amp;&amp; mytestvm.receivingItem != null)
      {
          ReceivingItemService s = new ReceivingItemService(p);
          s.Update(mytestvm.receivingItem);
          return RedirectToAction("Index");
  
      }
  
      return View(mytestvm);
  }
  </code></pre>
  
  <p><strong>View:</strong></p>
  
  <pre><code>@model FSIApps.Presentation.Models.ASideReceivingViewModel
  &lt;div class="row"&gt;
      @{Html.RenderPartial("POLineDetails", Model.poLine);}
  &lt;/div&gt;
  
  @using (Html.BeginForm("Receive", "Receiving", FormMethod.Post))
  {
  @Html.HiddenFor(model =&gt; model.receivingItem.Id)
  &lt;div class="row"&gt;
      &lt;div class="col-md-8 col-md-offset-2"&gt;
          &lt;div class="row"&gt;
              @Html.AntiForgeryToken()
              &lt;div class="col-md-6"&gt;
                  &lt;div class="form-group"&gt;
                      &lt;label for="receivingItem_Batch_number"&gt;Batch Number&lt;/label&gt;
                      @Html.TextBoxFor(model =&gt; model.receivingItem.Batch_number, new { @class = "form-control" })
                      &lt;span class="help-block"&gt;*Also the Vendor Lot Number on the BOL&lt;/span&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div class="col-md-6"&gt;
                  &lt;div class="form-group"&gt;
                      &lt;label for="receivingItem_Qty_received"&gt;Qty Received&lt;/label&gt;
                      @Html.TextBoxFor(model =&gt; model.receivingItem.Qty_received, new { @class = "form-control" })
                      &lt;span class="help-block"&gt;*Qty shown on BOL&lt;/span&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="row"&gt;
              &lt;div class="col-md-6"&gt;
                  &lt;div class="form-group"&gt;
                      &lt;label for="receivingItem_Carrier"&gt;Carrier&lt;/label&gt;
                      @Html.TextBoxFor(model =&gt; model.receivingItem.Carrier, new { @class = "form-control" })
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="col-md-6"&gt;
                  &lt;div class="form-group"&gt;
                      &lt;label for="receivingItem_"&gt;Tanker or Railcar&lt;/label&gt;
                      @Html.DropDownListFor(m =&gt; m.receivingItem.Tanker_or_railcar, new SelectList(Model.TankerOrRailcarOptions, "Key", "Value", Model.receivingItem.Tanker_or_railcar), new { @class = "form-control" })
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="row"&gt;
              &lt;div class="col-md-6"&gt;
                  &lt;div class="form-group"&gt;
                      &lt;label for="receivingItem_Railcar_number"&gt;Railcar Number&lt;/label&gt;
                      @Html.TextBoxFor(model =&gt; model.receivingItem.Railcar_number, new { @class = "form-control" })
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="col-md-6"&gt;
                  &lt;div class="form-group"&gt;
                      &lt;label for="receivingItem_Manifest_number"&gt;Manifest Number&lt;/label&gt;
                      @Html.TextBoxFor(model =&gt; model.receivingItem.Manifest_number, new { @class = "form-control" })
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class="row"&gt;
              &lt;div class="col-md-6"&gt;
                  &lt;div class="form-group"&gt;
                      &lt;input type="submit" value="Save" class="btn btn-success" /&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  }
  </code></pre>
  
  <p>I don't necessarily care about the data I send to the partial view, but when I post back the regular form I get nothing set in the ViewModel.  In the other post they talk about how that's an issue with naming the parameter sent back to the controller, but no combination of setting the value in my <code>@Html.BeginForm()</code> seems to do the trick.</p>
  
  <p>Anyone have any advice for me here?</p>
  
  <p>Edited:</p>
  
  <p><img src="https://i.stack.imgur.com/Fvqdk.png" alt="Visual Studio Break"></p>
  
  <p><img src="https://i.stack.imgur.com/9HBXm.png" alt="Fiddler Data"></p>