title: How to get the WebGrid selected row ID-value sent to controller?
body: <p>I have researched and cannot find an answer that I can use to pass the ID value back to the controller when user clicks on the SELECT cell of a WebGrid row using mvc4 asp.net vs2012.</p>
  
  <p>My WebGrid looks like this in the (partial) view:</p>
  
  <pre><code>@{
     ViewBag.Title = "Customers";
     WebGrid grid = new WebGrid(source: Model.oCustItems, canPage: false, rowsPerPage: 50, 
        selectionFieldName: "selectedRow",
        ajaxUpdateContainerId: "grid",      // pointer to the grid-control as defined with this new WebGrid call.
        sortFieldName: "Active", defaultSort: "Active");
  }
  
  &lt;div id="divForm" class="webgrid_div_container"&gt;
  @using (Html.BeginForm("GridRowClicked", "MainPage", FormMethod.Post))
  {
      @Html.Hidden("oValue", 1)
      grid.SelectedIndex=ViewBag.SelectedIndex;
      @grid.GetHtml(
      ...styling here... , 
      columns: grid.Columns(
          grid.Column(null,null, format: @&lt;input type="hidden" name="hidUID_CUSTOMER" value="@item.UID_CUSTOMER"/&gt;),
          grid.Column(columnName: "CustomerID", format: (item) =&gt; item.GetSelectLink(item.CustomerID.ToString()), header: "Select", style: "webgrid-select"),    
          grid.Column(columnName: "CompanyName", header: "Company Name"),
          grid.Column(columnName: null, header: "Inspection", format: @&lt;text&gt;06/28/2015&lt;/text&gt;),
          grid.Column(columnName: "Active", header: "Active?", format: @&lt;text&gt;&lt;input type="checkbox" checked="@item.Active" disabled="disabled" /&gt;&lt;/text&gt;)
                                  ),
          htmlAttributes: new { id = "MainTable" }
      )
  
      if (grid.HasSelection)
      {
          &lt;input type="hidden" id="UID_CUSTOMER" name="UID_CUSTOMER" value="@grid.SelectedRow["UID_CUSTOMER"]"/&gt;
          @Html.Hidden("UID_CUSTOMER", grid.SelectedRow["UID_CUSTOMER"])
      }
  
  }
  &lt;/div&gt;
  </code></pre>
  
  <p>Here is what I have discovered.</p>
  
  <ol>
  <li>The 'selectedRow' value does come into the controller.</li>
  <li>The 'UID_CUSTOMER' value always comes in as NULL.</li>
  <li>The (grid.hasSelection) fires AFTER the re-render after the return from controller.</li>
  </ol>
  
  <p>What I need is to obtain the 'UID_CUSTOMER' value (located in the first column (hidden) so that it is a valid value when actioned to the controller action.  But I cannot seem to find a way to obtain and send the value to the controller declared as:  </p>
  
  <pre><code>[HttpGet]
  public ActionResult Index(Int32? UID_CUSTOMER, Int32? selectedRow)
  {
  </code></pre>
  
  <p>Any help will be appreciated.
  I have pre-novice level jQuery and javascript skills, and beginner mvc skills (mainly web-forms .net skills) so please reply accordingly...Thanks...John</p>