title: MVC ModelBinding cannot get the label text to bind to a string property
body: <p>I'm trying to follow the pattern presented in the following post:</p>
  
  <p><a href="https://stackoverflow.com/questions/6749189/how-does-an-asp-net-mvc-model-generate-input-names">How does an asp.net MVC model generate input names?</a></p>
  
  <p>and I've run into a problem.  I've copied the code into my own application exactly as it is shown, but when the form is posted back the model has null for the RoleName property of the roles collection.  The values that are posted from the checkboxes are correct, but the RoleName is not binding.</p>
  
  <p>Below is the code that I'm using:</p>
  
  <p><strong>Register.cshtml</strong></p>
  
  <pre><code>@model SimpleMembershipTest.Models.RegisterViewModel
  @{
  ViewBag.Title = "Register";
  }
  
  &lt;hgroup class="title"&gt;
  &lt;h1&gt;@ViewBag.Title.&lt;/h1&gt;
  &lt;h2&gt;Create a new account.&lt;/h2&gt;
  &lt;/hgroup&gt;
  
   @using (Html.BeginForm()) {
  @Html.AntiForgeryToken()
  @Html.ValidationSummary()
  
  &lt;fieldset&gt;
      &lt;legend&gt;Registration Form&lt;/legend&gt;
      &lt;ol&gt;
          &lt;li&gt;
              @Html.LabelFor(m =&gt; m.UserName)
              @Html.TextBoxFor(m =&gt; m.UserName)
          &lt;/li&gt;
          &lt;li&gt;
              @Html.LabelFor(m =&gt; m.FirstName)
              @Html.TextBoxFor(m =&gt; m.FirstName)
          &lt;/li&gt;
          &lt;li&gt;
              @Html.LabelFor(m =&gt; m.LastName)
              @Html.TextBoxFor(m =&gt; m.LastName)
          &lt;/li&gt;
          &lt;li&gt;
              @Html.LabelFor(m =&gt; m.Password)
              @Html.PasswordFor(m =&gt; m.Password)
          &lt;/li&gt;
          &lt;li&gt;
              @Html.LabelFor(m =&gt; m.ConfirmPassword)
              @Html.PasswordFor(m =&gt; m.ConfirmPassword)
          &lt;/li&gt;
          &lt;li&gt;
              @Html.LabelFor(m =&gt; m.Email)
              @Html.TextBoxFor(m =&gt; m.Email)
          &lt;/li&gt;
      &lt;/ol&gt;
      &lt;div class="roleCheckBoxes"&gt;
              @Html.EditorFor(m =&gt; m.Roles)
          &lt;/div&gt;
      &lt;input type="submit" value="Register" /&gt;
  &lt;/fieldset&gt;
  }
  
  @section Scripts {
  @Scripts.Render("~/bundles/jqueryval")
  }
  </code></pre>
  
  <p><strong>RegisterViewModel.cs</strong></p>
  
  <pre><code>namespace SimpleMembershipTest.Models
  {
  public class RegisterViewModel
  {
  [Required]
  [Display(Name = "User name")]
  public string UserName { get; set; }
  
  [Required]
  [Display(Name = "First name")]
  public string FirstName { get; set; }
  
  [Required]
  [Display(Name = "Last name")]
  public string LastName { get; set; }
  
  [Required]
  [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
  [DataType(DataType.Password)]
  [Display(Name = "Password")]
  public string Password { get; set; }
  
  [DataType(DataType.Password)]
  [Display(Name = "Confirm password")]
  [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
  public string ConfirmPassword { get; set; }
  
  [Required]
  [EmailAddress]
  [Display(Name = "Email")]
  public string Email { get; set; }
  
  public IEnumerable&lt;RoleViewModel&gt; Roles { get; set; }
    }
  }
  </code></pre>
  
  <p>RoleViewModel.cs</p>
  
  <pre><code> @model SimpleMembershipTest.Models.RoleViewModel
  
  @Html.CheckBoxFor(m =&gt; m.Selected)
  @Html.LabelFor(m =&gt; m.Selected, Model.RoleName)
  </code></pre>
  
  <p>AccountController.cs</p>
  
  <pre><code>[AllowAnonymous]
  public ActionResult Register()
  {
    var roles = Roles.GetAllRoles();
    var model = new RegisterViewModel
    {
      Roles = roles.Select(role =&gt; new RoleViewModel
      {
        RoleName = role,
        Selected = false
      })
    };
    return View(model);
  }
  </code></pre>
  
  <p>I'm probably missing something obvious, but I can't seem to see it.  Any help would be greatly appreciated.</p>