Sorting / Paging two webgrid in MVC 3 Razor

When using two webgrids, you often must have come across a problem where sorting/paging on one webgrid will affect the sorting and paging on the other grid. Now lets assume you have already set canPage: true, canSort: true

Below is a simple example of how you should use multiple webgrids to avoid this problem.

string fieldNamePrefix = null  
//The value which prefixes the default querystring fields
string pageFieldName = null  
//A value that replaces the default querystring page field
var grid1 = new WebGrid(ajaxUpdateContainerId: "grid1", fieldNamePrefix:"g1",pageFieldName: "p1");
var grid2 = new WebGrid(ajaxUpdateContainerId: "grid2", fieldNamePrefix:"g2",pageFieldName: "p2");