How to change the default sort order to descending?
How do I change the defaultSort
of my webGrid
to be in the opposite/descending order? If it were SQL, I'd be adding a DESC
somewhere. Here's my working line of code for an Ascending sort:
var grid = new WebGrid(dq, rowsPerPage: 50, defaultSort: "UWDate", ajaxUpdateContainerId: "grid" );
It correctly sorts on the UWDate
column in Ascending order, but I would like it to sort the opposite/descending order.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Another option is after your grid initialization:
You can change the sort order within the
WebGrid
initialiser by putting a space followed byDESC
within thedefaultSort
parameter string.Source: http://forums.asp.net/post/4962796.aspx
If you are using entity framework then you can use this syntax for ordering to descending order.
This is the design view syntax for the grid print of the model.