webgrid sorting not working

Total Post:52

Points:366
 710  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. Post:45

    Points:323
    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