title: Implementing checkbox list from list in ASP.NET Core
body: <p>I've seen the other threads on the subject, but am having trouble with what I believe is the correct syntax/setup. Ultimately the controller is not able to see the contents of the Role list when it is being returned from an edit.</p>
  
  <p>View</p>
  
  <pre><code>@model Models.Volunteer
  
              @foreach (var item in Model.Roles)
              {
                  &lt;input type="checkbox" asp-for="@item.Selected" /&gt;
                  &lt;label asp-for="@item.Selected"&gt;@item.RoleName&lt;/label&gt;
                  &lt;input type="hidden" asp-for="@item.RoleId" /&gt;
                  &lt;input type="hidden" asp-for="@item.RoleName" /&gt;
                  &lt;br /&gt;
              }
  
  &lt;input type="submit" value="Save" class="btn btn-default" /&gt;
  </code></pre>
  
  <p>Model</p>
  
  <pre><code>public abstract class BaseVolunteer
  {
      [Key]
      public int Recno { get; set; }
      public string FirstName { get; set; }
      public string LastName { get; set; }
      public string Email { get; set; }
      public string City { get; set; }
      [NotMapped]
      [Display(Name = "Roles")]
      public List&lt;Role&gt; Roles { get; set; }
  }
  
  public class Role
  {
      [Key]
      public String RoleId { get; set; }
      public String RoleName { get; set; }
  
      public bool Selected { get; set; }
  }
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code>    [HttpPost]
      [ValidateAntiForgeryToken]
      public async Task&lt;IActionResult&gt; Edit(int id, [Bind("Recno,FirstName,LastName,Email,City,Roles")] Volunteer volunteer)
      {
  }
  </code></pre>
  
  <p>The volunteer object in the controller correctly returns the other values... but the Roles object is NULL despite being properly populated for display.</p>