title: MVC POST to controller action and pass param from listview?
body: <p>Im working on a project and another devloper has some code like this...</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function submitForm() {
          document.forms[0].submit();
      }
  &lt;/script&gt;       
  
  
  @foreach (var product in Model)
  {
      using (Html.BeginForm("SelectProduct", "Home", new {productId = product.Id}))
      {
      &lt;tr&gt;
          &lt;td&gt;
              &lt;a href="#" id="submit_form" onclick="submitForm();"&gt;@product.Id&lt;/a&gt;
          &lt;/td&gt;
          &lt;td&gt;
              @product.Name
          &lt;/td&gt;
      &lt;/tr&gt;
      }
  }
  </code></pre>
  
  <p>It builds a 2 column table with clickable products ids, and product names.
  It posts to a SelectProduct action on the home controller when clicking a productId</p>
  
  <pre><code>[HttpPost]
  public ActionResult SelectProduct(Guid productId)
  {
     ...
  }
  </code></pre>
  
  <p>I like this because it is a POST and doesnt send the productId in the url\querystring.
  (I changed the code for this example, these arnt really productIds and id prefer to not have this data in the url)</p>
  
  <p>But i dont like this because...</p>
  
  <ul>
  <li>It doesnt work because it always posts form[0]</li>
  <li>Not sure i like how it creates a form for every product</li>
  <li>It is messing up my jquery mobile listview I am working on, the formatting is all strange. I'm not exactly sure why but think because of the forms.</li>
  </ul>
  
  <p>In contrast i have a the following listview with anchor tags and that renders just fine.</p>
  
  <pre><code>&lt;ul data-role="listview" data-inset="true" data-dividertheme="b"&gt;
      &lt;li&gt;&lt;a href="@Url.Action("Index", "SomeControllerA")"&gt;Some Controller A&lt;/a&gt; &lt;/li&gt;
      &lt;li&gt;&lt;a href="@Url.Action("Index", "SomeControllerB")"&gt;Some Controller B&lt;/a&gt; &lt;/li&gt;
      &lt;li&gt;&lt;a href="@Url.Action("Index", "SomeControllerC")"&gt;Some Controller C&lt;/a&gt; &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>So my questions is...</p>
  
  <p>How can I make a similar table / list of products with the same functionality (i.e. click a productID and POST to a controller action passing productId but not in querystring) without using seperate repeating forms?</p>
  
  <p>I was thinking maybe just 1 form, but somehow the proper productID gets passed to controller.  This way i could have the <em>Html.BeginForm</em> outside the <em>@foreach (var product in Model)</em>.  </p>
  
  <p>I think I'm trying to do something somewhat similar to what web forms LinkButton used to do in a grid.
  It's like i want ActionLinks but i want them to POST instead of GET.</p>
  
  <p>Appreciate any help.</p>
  
  <p>Thanks!</p>