title: .NET MVC 4 - Button actions in a foreach loop
body: <p>I've currently got a View like this:</p>
  
  <pre><code>@using (Html.BeginForm("Compare", "Carousel", FormMethod.Post)) 
  {
  @foreach (var product in Model.Products)
  {
          &lt;tr&gt;
               &lt;td&gt;@product.Provider.Name&lt;/td&gt;
               &lt;td&gt;&amp;pound;@Math.Round(product.MonthlyPremium, 2, MidpointRounding.AwayFromZero)&lt;/td&gt;
               &lt;td&gt;@Html.ActionLink("More Details", "MoreDetails", new { id = product.ProductId })&lt;/td&gt;
               &lt;td&gt;&lt;button name="compare" value="@product.ProductId"&gt;Compare&lt;/button&lt;/td&gt;
          &lt;/tr&gt;
  }
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>[HttpPost]
  public ActionResult Compare(ProductsWithDetailModel model) // This is a guess, Model may not persist? 
   {
         // Code here
  
         return View("Index", model);
   }
  </code></pre>
  
  <p>What I actually want is, when a button is clicked, the Controller is going to be called and the product that has been selected (the button clicked) will be added to a list of items.</p>
  
  <p>How do I actually find out which button has been clicked in the Controller? How come I cant find <em>any</em> tutorials out there on the web that have done this before, surely its basic functionality? Or am I approaching it wrong?</p>