title: ASP.NET MVC: Use Html.CheckBoxFor() to collect list of string values when checked
body: <p>In my web application I have a page with a list of "Requests" that an administrator can either Approve or Deny in bulk. So the page would look something like:</p>
  
  <pre><code>[x] Request 1
  [ ] Request 2
  [x] Request 3
  [ ] Request 4
  
  [Approve Selected]   [Deny Selected]
  </code></pre>
  
  <p>My model looks something like:</p>
  
  <pre><code>public class RequestManagementModel
  {
      public List&lt;string&gt; LicenseIdsToProcess { get; set; }
      public List&lt;Resource&gt; Resources { get; set; }
      // additional fields
  }
  </code></pre>
  
  <p>And in my view, I have:</p>
  
  <pre><code>int counter = 0;
  @foreach (Resource r in Model.Resources)
  {
      &lt;tr&gt;
          &lt;td&gt;
              @Html.CheckBoxFor(model =&gt; model.LicenseIdsToProcess[counter++], new { value = r.RequestId })
          &lt;/td&gt;
      &lt;/tr&gt;
  }
  </code></pre>
  
  <p>And of course my controller action accepts the model on form post</p>
  
  <pre><code>public ActionResult ProcessRequests(RequestManagementModel model, ProcessType type)
  {
      // process requests here
  }
  </code></pre>
  
  <p>So, as you might expect, I'm getting an error in the view on <code>model.LicenseIdsToProcess[counter++]</code> that says "Cannot implicitly convert type 'string' to 'bool'". It doesn't like the fact that I'm trying to use checkboxes to represent a list of values that a user can select one or many from, rather than a single true/false.</p>
  
  <p>I'd like this to be set up so that, for every checkbox the user selects, that string id value is bound to the list of id's in my model when the form is posted. I know how to do it just by using <code>&lt;input type="checkbox"&gt;</code>, because I can set the value of the checkbox there. But is there a way to use it with Html.CheckBoxFor to achieve strong typing through model binding?</p>
  
  <p>Thanks.</p>