title: In MVC/Razor, how do I get the values of multiple checkboxes and pass them all to the controller?
body: <p>I have a view with a list of items from a model.  I need to add a checkbox to each row, have the user select multiple check boxes, and pass some identifier of what row was selected to the controller.  I know how to pass a single value through an action link, but I'm not sure how to pass multiple values through an action link or how to "collect" which rows were selected.  I'll show some of my code attempts below.  Can someone help me sort out why I can't get the values of all the checkboxes passed to the controller?</p>
  
  <p>Here's my page</p>
  
  <pre><code>Checkbox     App ID     Date     Name
     []          1        5/10     Bob
     []          2        5/10     Ted
     []          3        5/11     Alice
  </code></pre>
  
  <p>What I need the user to do is select rows 1 &amp; 3 (for example) and have those App ID's passed to the controller.</p>
  
  <p>I started listing various attempts, but decided just to show my current attempt and see if anyone could point out what I'm doing wrong.  The main difference I see between examples online and mine is that mine uses a PagedList and creates the rows of the table in a foreach loop.</p>
  
  <p>The parameter ints is blank when it hits the controller.  How do I get the values from the checkboxes into it?  I used this site for the basic idea of naming all the checkboxes the same and passing a ICollection through the action link:
  <a href="http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx/">http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx/</a></p>
  
  <p>View:</p>
  
  <pre><code>@model PagedList.IPagedList&lt;CarmelFinancialWeb.Models.ModelMerchantSummary&gt;
  &lt;div class="block" style="width: 100%; float: left"&gt;
  &lt;p class="block-heading"&gt; 
  Merchant Application Report
  &lt;/p&gt;
  &lt;div class="table-holder"&gt;
      &lt;table class="table" style="margin-bottom: 0px"&gt;
              &lt;tbody&gt;
                  @foreach (var item in Model)
                  {
                      &lt;tr&gt;
                          &lt;td&gt;
                              &lt;input type="checkbox" name="ints" value=item.ApplicationID /&gt;
                          &lt;/td&gt;
                      &lt;td&gt;
                          @Html.ActionLink(item.ApplicationID.ToString(), "ViewApplication", new { ID = item.ApplicationID, edit = 1 }, new AjaxOptions { HttpMethod = "GET" })
                      &lt;/td&gt;
                      &lt;td&gt;
                          @Convert.ToDateTime(item.ApplicationDate).ToString("M/d/yy")
                      &lt;/td&gt;
                      &lt;td&gt;
                          @item.ApplicantName
                      &lt;/td&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  @Html.ActionLink("Print Application", "PrintApplication", "CreateContract", new { @class = "btn btn-primary" })
  </code></pre>
  
  <p></p>
  
  <p>Controller:</p>
  
  <pre><code>    [AuthorizeAdmin]
      public ActionResult PrintApplication(ICollection&lt;int&gt; ints, string ID)
      {
          Contracts_Create contract = new Contracts_Create();
          ModelApplication currentApplication = new ModelApplication();
          currentApplication.contract = new ModelContract();
          return File(contract.CreatePDF_PrintedApplication_English(currentApplication.contract.location, currentApplication.contract), "application/pdf");
      }
  </code></pre>
  
  <p>Edit:
  This got tagged as a duplicate of another question.  The question there was about whether non-sequential input names could be used.  My problem is that I'm using inputs that are not non-sequential, but it is still not working.  I understand the concept, I just can't figure out why my specific code is not working.  I've put a lot of time into this and can't find the answer to my specific code.  Thanks!</p>