title: MVC 3 Razor pass webgrid row data to controller using actionlink
body: <p>I have a webgrid with an actionlink which I want to use to edit the selected row in a new view. I know that I can use an actionlink to supply an arguement to my actionresult method but I don't know how to pass the webgrid's row data to my controller apart from using actionlink.</p>
  
  <pre><code>@{
      ViewBag.Title = "Index";
  }
  &lt;h2&gt;
      Index&lt;/h2&gt;
  &lt;p&gt;
      @Html.ActionLink("Create New User", "CreateUser")
  &lt;/p&gt;
  &lt;div class="webgrid-wrapper"&gt;
      @model IEnumerable&lt;UserManager.Models.vw_UserManager_Model_Add_Users&gt;
  @{
      ViewBag.Title = "Jobs";
      WebGrid grid = new WebGrid(Model, canPage: true, canSort: true, rowsPerPage: 15, selectionFieldName: "selectedRow", fieldNamePrefix: "gridItem");
  
  }
      @grid.GetHtml(
      fillEmptyRows: true,
          tableStyle: "webgrid",
                  alternatingRowStyle: "webgrid-alternating-row",
                  headerStyle: "webgrid-header",
                  footerStyle: "webgrid-footer",
                  selectedRowStyle: "webgrid-selected-row",
              rowStyle: "webgrid-row-style",
          mode: WebGridPagerModes.All,
  columns: new[] {
      //grid.Column("ApplicationId"),
      //grid.Column("salutation"),
  
      //grid.Column("PasswordSalt"),
  
       grid.Column("FirstName"),
  
      //grid.Column("LoweredEmail"),
      //grid.Column("PasswordQuestion"),
      //grid.Column("PasswordAnswer"),
  
      // grid.Column("PasswordFormat"),
      grid.Column("LastName"),
      grid.Column("Password"),
      grid.Column("isactive"),
      //grid.Column("IsLockedOut"),
      grid.Column("email"),
     grid.Column("module_name"), 
  
      //grid.Column("LastLoginDate"),
      //grid.Column("LastPasswordChangedDate"),
      //grid.Column("LastLockoutDate"),
  
      //grid.Column("FailedPasswordAttemptCount"),
      //grid.Column("FailedPasswordAttemptWindowStart"),
      //grid.Column("FailedPasswordAnswerAttemptCount"),
      //grid.Column("FailedPasswordAnswerAttemptWindowStart"),
     // Rest of grid columns, seen previously
      @*grid.Column(
         "",
          header: "Actions",
          format: @&lt;text&gt;
      @Html.ActionLink("Edit", "Edit", new { id = item.email }) 
      &lt;/text&gt;
      )   , 
       grid.Column(
         "",
          header: "Actions",
          format: @&lt;text&gt;
      @Html.ActionLink("Delete", "Delete", new { id = item.email })
      &lt;/text&gt;
      )    *@
  @*     grid.Column(
              header:"", 
              format:@&lt;text&gt;&lt;div id="btnSelectedRow"&gt;
                  "@item.GetSelectLink("Edit")&lt;/div&gt;&lt;/text&gt;
              ),*@
  
  
       grid.Column(
              header:"", 
              format:@&lt;text&gt;&lt;div id="btnSelectedRow"&gt;
                  "@Html.ActionLink("Edit record", 
                          "EditUser",
                          "UserManager",
                                         new {selectedRow = grid.SelectedRow },
                          null
                          )&lt;/div&gt;&lt;/text&gt;
              )
  })
      @if (grid.HasSelection)
      {
          var record = grid.SelectedRow;
  @*@RenderPage("~/Views/UserManager/EditUser.cshtml", new { record = grid.SelectedRow })*@
  
      }
  &lt;/div&gt;
  &lt;script type="text/javascript"&gt;
      $(document).ready(function () {
          function jQueryUIStyling() {
              $('input:button, input:submit').button();
  
              // Style tables.
              $('.webgrid-wrapper').addClass('ui-grid ui-widget ui-widget-content ui-corner-all');
              $('.webgrid-title').addClass('ui-grid-header ui-widget-header ui-corner-top');
              jQueryTableStyling();
          }
  
          //
          // Style tables using jQuery UI theme. This function is 
          // split out separately so that it can be part of the AJAX
          // callback of the WebGrid WebHelper in ASP.NET MVC.
          //
          function jQueryTableStyling() {
              $('.webgrid').addClass('ui-grid-content ui-widget-content');
              $('.webgrid-header').addClass('ui-state-default');
              $('.webgrid-footer').addClass('ui-grid-footer ui-widget-header ui-corner-bottom ui-helper-clearfix');
          }
      });
  
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>My controller</strong></p>
  
  <pre><code> public ActionResult EditUser(System.Web.Helpers.WebGrid record)
          {
              record.ToString();
  
              return View();
          }
  </code></pre>
  
  <p><strong>Summary</strong></p>
  
  <p>How to pass row data using ActionLink from one view to another via ActionResult method.</p>