HI, I 'm trying to sort the rows in my datatable using select method. I know that i can say
你好,我正在尝试使用select方法对我的datatable中的行进行排序。我知道我可以说
datatable.select("col1='test'")
which in effect is a where clause and will return n rows that satisfy the condition.
它实际上是where子句,返回满足条件的n行。
I was wondering can i do the following
我在想我能做以下的事情吗
datatable.select("ORDER BY col1")
---col1 is the name of hte column
数据表。选择(“ORDER BY col1”)--col1是hte列的名称
I tried datatable.defaultview.sort()
but didnt work
我试过datatable.defaultview.sort(),但是没用
Any ideas on how to get around this issue. thanks
关于如何解决这个问题有什么想法吗?谢谢
3 个解决方案
#1
42
Have you tried using the DataTable.Select(filterExpression, sortExpression) method?
您试过使用DataTable了吗?选择(filterExpression sortExpression)方法?
#2
20
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.
通过上述方法,您将能够对N列进行排序。
#3
19
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.
那将解决你的问题。
#1
42
Have you tried using the DataTable.Select(filterExpression, sortExpression) method?
您试过使用DataTable了吗?选择(filterExpression sortExpression)方法?
#2
20
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.
通过上述方法,您将能够对N列进行排序。
#3
19
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.
那将解决你的问题。