title: How to capture selected row ID - MVC Table
body: <p>I have table layout in MVC (see below code), on each table row I have a submit button. Each Submit button post to same controller method 'TableSample'. How to capture the selected row id and post it?</p>
  
  <pre><code>public class TableSample
  {
      public string Property1 { get; set; }
  
      public string Property2 { get; set; }
  
      public int Property3 { get; set; }
  
      public List&lt;Things&gt; Things;
  }
  
  @Html.TextBoxFor(m =&gt; m.Property1)
  @Html.TextBoxFor(m =&gt; m.Property2)
  @Html.TextBoxFor(m =&gt; m.Property3)
  &lt;table&gt;
      &lt;tbody&gt;
      @foreach (var thing in Model.Things)
      {
          &lt;tr&gt;
              &lt;td&gt;@thing.ID&lt;/td&gt;
              &lt;td&gt;@thing.Name&lt;/td&gt;
              &lt;td&gt;&lt;input type="submit" value="Select" name="Command" /&gt;&lt;/td&gt;
          &lt;/tr&gt;
      }
      &lt;/tbody&gt;
  &lt;/table&gt;
  
  
  [HttpPost]
  public ActionResult TableSample(TableSample sample, string Command)
  {
      if (Command == "Select")
      {
          //How to capture selected row ID?
      }
  
      if (Command == "Other")
      {
  
      }
  }   
  </code></pre>