title: jqGrid - The parameters dictionary contains a null entry for parameter 'page' of non-nullable type 'System.Int32' '
body: <p>I am new to jqGrid and has been struggling to use it within an MVC3 project with no success. I have downloaded the <a href="http://www.trirand.com/blog/jqgrid/downloads/jqgrid_demo40.zip" rel="nofollow">demo</a> and gone through the code but implementing the jqGrid within my project fails with the following error.</p>
  
  <pre><code>The parameters dictionary contains a null entry for parameter 'page' of non-nullable type
  'System.Int32' for method 'System.Web.Mvc.JsonResult Index(System.String, System.String,
  Int32, Int32)' in 'kags.Web.Controllers.DeptController'. An optional parameter must 
  be a reference type, a nullable type, or be declared as an optional parameter.
  Parameter name: parameters
  </code></pre>
  
  <p>The following is the code in controller:</p>
  
  <pre><code>public JsonResult Index(string sidx, string sord, int page, int rows){
      var ascending = sord.StartsWith("asc") ? true : false;
      int pageIndex = Convert.ToInt32(page) - 1;
      int pageSize = rows;
      int startRow = (pageIndex *  pageSize) + 1;
      var depts = ListAll()
              .Skip(startRow)
              .Take(pageSize).AsQueryable()
              .OrderByField(sidx, ascending);
      int totalRecords = depts.Count();
      int totalPages = (int) Math.Ceiling((float) totalRecords/ (float) pageSize);
  
      var jsonData = 
                new { total = totalPages,
                      page = page, 
                      records = totalRecords, 
                      rows = (from d in depts
                              select new {
                                 i = d.Id,
                                 cell = new string[]{d.Name, d.Version.ToString()}
                              })
                              .ToArray()  
                    };
          return Json(jsonData, JsonRequestBehavior.AllowGet);
      }
  </code></pre>
  
  <p>The following is the index.cshtml</p>
  
  <pre><code>&lt;h2&gt;Available Depts&lt;/h2&gt;
  &lt;div&gt;
      &lt;table id="List" class="scroll" cellpadding="0" cellspacing="0"&gt;&lt;/table&gt;
      &lt;div id="pager" class="scroll" style="text-align:center;"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The css and script files for the jqGrid are being loaded from the _Layout.cshtml in shared and are arranged in the correct order.</p>
  
  <p>The following script to support the jqGrid resides in a separate script file</p>
  
  <pre><code>jQuery(document).ready(function () {
          ("#List").jqGrid({
              url: '/Dept/Index/',
              datatype: 'json',
              mtype: 'POST',
              colNames: ['Name'],
              colModel: [{ name: 'Name', index: 'Name', width: 300, align: 'left'}],
              pager: jQuery('#pager'),
              rowNum: 10,
              rowList: [5, 10, 20, 50],
              sortname: 'Id',
              sortOrder: "desc",
              viewrecords: true,
              caption: 'Dept List'
          });
      });
  </code></pre>
  
  <p>I have looked at other <a href="http://haacked.com/archive/2009/04/13/using-jquery-grid-with-asp.net-mvc.aspx" rel="nofollow">samples</a> but still I am unable to locate why I am getting the error. </p>
  
  <p>I would appreciate if someone can point me in the right direction to resolve the error and manage to populate the grid.</p>