title: ASP.Net MVC4 ViewModel null properties and HttpPost
body: <p>I have the following ViewModel:</p>
  
  <pre><code>public class MyViewModel
  {
      public int Id { get; set; }
      public string Title { get; set; }
      public int ParentClassId { get; set; }
      public List&lt;AnotherClass&gt; AnotherClassItems { get; set; }
  }
  </code></pre>
  
  <p>And in the view I only have a form input for Title, and a list of AnotherClassItems that aren't editable - they are just used to display a list of items related to the class. All of the properties are set when the 'edit' view loads, but when the view does a post, the ParentClassId &amp; AnotherClassItems lists are null. Here is the HttpPost ActionResult from the controller:</p>
  
  <pre><code>[HttpPost]
  public ActionResult Edit(FormCollection collection, MyViewModel myviewmodel)
  {
  
       if (ModelState.IsValid)
       {
  
         //myviewmodel.ParentClassId and myviewmodel.AnotherClassItems are null??
       }
       return View(myviewmodel);
  }
  </code></pre>
  
  <p>Is there a way to pass the ParentClassId &amp; AnotherClassItems properties without having them as form inputs in the view? Or should I use the Viewbag for this?</p>