title: How do I bind to a List as a Property on a Model in MVC 3 Razor?
body: <p>I've got a model that looks something like this:</p>
  
  <pre><code>public class EditUserViewModel
      {
          public EditUserViewModel()
          {
  
          }
          public EditUserDataModel User { get; set; }
      }
  </code></pre>
  
  <p>With a backing object that looks like this:</p>
  
  <pre><code>public class EditUserDataModel
  {
      public EditUserDataModel()
      {
          Roles = new List&lt;UserRoleListDataModel&gt;();
      }
      [DisplayName("First Name")]
      public string FirstName { get; set; }
      [DisplayName("Last Name")]
      public string LastName { get; set; }
      [DisplayName("Full Name")]
      public string FullName { get { return FirstName + " " + LastName; } }
      public List&lt;UserRoleListDataModel&gt; Roles { get; set; }
  }
  </code></pre>
  
  <p>And UserRoleListDataModel looks like this:</p>
  
  <pre><code>public class UserRoleListDataModel
  {
      public Guid Id { get; set; }
      public string RoleName { get; set; }
      public bool UserIsInRole { get; set; }
  }
  </code></pre>
  
  <p>Then, in my Razor file, I am using the whole thing like so:</p>
  
  <pre><code>@foreach (var role in Model.User.Roles)
  {
  &lt;tr&gt;
      &lt;td&gt;@role.RoleName&lt;/td&gt;
      &lt;td&gt;@Html.CheckBoxFor(x=&gt;role.UserIsInRole)&lt;/td&gt;
  &lt;/tr&gt;
  }
  </code></pre>
  
  <p>The problem I'm having, is when I submit the form and hit my controller action, the Roles list is not populated on my new model.</p>
  
  <p>Here is what the submit action on the controller looks like:</p>
  
  <pre><code>public ActionResult EditUser(EditUserViewModel model) // model.User.Roles is empty.
  {
      // Do some stuff...
      return RedirectToAction("UserList");
  }
  </code></pre>
  
  <p>Anyone have any suggestions?</p>