when i add the web grid to my page in mvc project it sortes the data ascending on first click. but i bring the data already sorted ascendin. then nothing happens. i want webgrid to sort descending at first.
you can see the code of my grid creation
var grid = new WebGrid(Model, canPage: true, rowsPerPage: 5,
selectionFieldName: "selectedRow",ajaxUpdateContainerId: "gridContent");
grid.Pager(WebGridPagerModes.NextPrevious);
by the way i have tried the below code but it doesnt work.
if (Request.QueryString[grid.SortDirectionFieldName].IsEmpty())
{
grid.SortDirection = SortDirection.Descending;
}
Try adding a
defaultSortproperty to yourWebGridinstantiator: