title: Using paging with WebGrid in MVC4
body: <p>This is the code in my view. The WebGrid Sort and Filter is working fine. I am trying to implement paging which is not happening.</p>
  
  <p>View:</p>
  
  <pre><code>    @{        
      var grid = new WebGrid(null,
              defaultSort: "",
              rowsPerPage: 10,
              selectionFieldName:"SearchString",
              ajaxUpdateContainerId:"agrid",
              sortFieldName:"SortColumn",
              sortDirectionFieldName:"SortOrder");
      grid.Bind(Model, autoSortAndPage: true, rowCount:20);
  }
  
  &lt;div id="agrid"&gt;
  @grid.GetHtml(
      tableStyle: "webGrid",
      headerStyle: "header",
      alternatingRowStyle: "alt",
      columns: grid.Columns(
          grid.Column("ID"),
          grid.Column("Description")
      )
  )
   &lt;/div&gt; 
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>        public ActionResult Index(int? page=1, int currentPage = 1, int PageSize = 10, string SortColumn = "", string SortOrder = "", string SearchString = "", int numberOfPages=0, int tr=0)
      {
          DataContextDataContext obj = new DataContextDataContext();
          System.Nullable&lt;int&gt; Total = null;
  
  
          var model = obj.TempItemSubClassList(page, PageSize, SortColumn, SortOrder, SearchString, ref Total).ToList();
          tr = (int) Total;
  
          numberOfPages = (int)(Total + PageSize - 1) / PageSize;
  
          return View(model);
  
          //var itemsubclasses = db.ItemSubClasses.Include(i =&gt; i.ItemClass);
          //return View(itemsubclasses.ToList());
  
      }
  </code></pre>