Page Size is obtained thorugh -> HttpContext.Current.Request["rows"]; //No of records in a page
Page Number is obtained trhugh -> HttpContext.Current.Request["page"]; // page number
Sort Column Header is obtained through -> HttpContext.Current.Request["sidx"]; //column of grid to sort
and Sort Order is obtained thorugh -> HttpContext.Current.Request["sord"]; //ascending/descending
(Remember Sort Coulmn will be the name given to column model defined in jQGrid that may or may not be equivalent to DataBaseColumn).
To handle sorting, execute the database query to fill poulate the jQGrid with additonal sorting coulmns and sorting order. which returns the results as collection of DataContract( http://msdn.microsoft.com/en-us/library/ms733127.aspx) defined in WCF service.
Now to handle paging, i wrote following commands at my WCF end:
Public GridData(required params,1,2...)
{
//some initial code
List<DataContract1> lstrawData = ...//Get the actual results here (rows after sorting)
int pageSize = Convert.ToInt32(HttpContext.Current.Request["rows"]);
int page = Convert.ToInt32(HttpContext.Current.Request["page"]);
int rowsCount = lstrawData.Count;
int innerRows = rowsCount - ((page - 1) * pageSize);
//SKIP() and Take() are keywords used in LINQ to get paged data
List<DataContract1> pagedList = lstrawData.Skip((page - 1) * pageSize).Take(pageSize).ToList();
//GridData is another DataContract defined in WCF service which is being rturnde and bound to jQgrid
GridData gridData = new GridData();
gridData.page = page;
gridData.records = rowsCount;
gridData.total = (rowsCount % pageSize) == 0 ? rowsCount % pageSize : rowsCount / pageSize + 1;
gridData.rows = pagedList;
return gridData ; //this contains the actual paged data with page, pagesize, totalNumber of rows details.
}