title: Webgrid with filtered results
body: <p>I like the Webgrid HTML-Helper in Razor-ViewEngine.</p>
  
  <p>Unfortunatly I am facing a problem. Using the built-in sorting and paging functions I loose my filter settings.</p>
  
  <p>Above the grid I have a filtercontrol (form), filtering the rows shown in the grid by filling a filter-class and calling an actionmethode on the controller when submitting.</p>
  
  <p>Code in Controller:</p>
  
  <pre><code>public ActionResult DeliveryContractList(SampleClassFilter filter){
  
     // Populate a filtered List of Items to Show    
     IList&lt;SampleClass&gt; model = FillList(filter);
  
     // Return a View with the List.
     return View("SampleClassList", model);
  
  }
  </code></pre>
  
  <p>The View:</p>
  
  <pre><code>  @model IEnumerable&lt;SampleClass&gt;
    @{
        ViewBag.Title = "SampleClassList";
    }
  
    @using(Html.BeginForm()){
          // Form to Set the Filter
          ...
    }
  
    &lt;div id = "SampleClassList"&gt;
  
      var grid = new WebGrid(Model, canPage: true, canSort: true, ajaxUpdateContainerId: "SampleClassList");
  
      @grid.GetHtml(htmlAttributes: new {id = "gridSampleClass"}, columns:
          grid.Columns(
              grid.Column("Foo", "For", canSort: true),
              grid.Column("Bar", "Bar", canSort: true),
          )
       ); 
  &lt;/div&gt;
  </code></pre>
  
  <p>I recognized that when clicking e.g. the column header of the grid to sort the action methode in the controller is called too. Of course the filter class is null leading to an unfiltered resultset.</p>
  
  <p>Is there a way to keep my results filtered when sorting or paging the webgrid?
  I don't want to use jquery!!!</p>
  
  <p>Thanks in advance
  Tobi</p>
  
  <hr>
  
  <p>Is it possible to define parameters added to the link called when clicking on a sort or page link?</p>