Datatable select method ORDER BY clause

限于喜欢 提交于 2019-12-20 11:11:01

问题


HI, I 'm trying to sort the rows in my datatable using select method. I know that i can say

datatable.select("col1='test'")

which in effect is a where clause and will return n rows that satisfy the condition.

I was wondering can i do the following

datatable.select("ORDER BY col1") ---col1 is the name of hte column

I tried datatable.defaultview.sort() but didnt work

Any ideas on how to get around this issue. thanks


回答1:


Have you tried using the DataTable.Select(filterExpression, sortExpression) method?




回答2:


Use

datatable.select("col1='test'","col1 ASC")

Then before binding your data to the grid or repeater etc, use this

datatable.defaultview.sort()

That will solve your problem.




回答3:


You can use the below simple method of sorting:

datatable.DefaultView.Sort = "Col2 ASC,Col3 ASC,Col4 ASC";

By the above method, you will be able to sort N number of columns.



来源:https://stackoverflow.com/questions/1274976/datatable-select-method-order-by-clause

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!