webgrid sorting not working

Posted by  Manish Kumar
 1020  View(s)
Ratings:
Rate this:

webgrid sorting not working

I'm using webgrid to show data from my data base. i want to show date wise record.

here is my code

@{

    var grid = new WebGrid(Model, canSort: true, canPage: true, rowsPerPage: 50, sortFieldName: "Active", default:"PostedDate" ajaxUpdateContainerId: "updategrid");
}
  1. Re: webgrid sorting not working

    You can try this

    @{
        var grid = new WebGrid(Model.OrderByDescending(x=>x.PostedDate), canSort: true, canPage: true, rowsPerPage: 50, sortFieldName: "Active",  ajaxUpdateContainerId: "updategrid");
    }

Answer