排序功能 [英] Sort Function
本文介绍了排序功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可能真的很胖...但是我有这个问题要问我.我看不到任何错误.任何评论表示赞赏.
Hi,
I''m probably being really thick... but I have this question ask of me. I can''t see anything wrong. Any comments appreciated.
This function, although it will successfully sort a datatable, has a major problem with it. What is the problem?
<pre lang="vb">Private Function sorttable(ByVal dt As DataTable, ByVal sorttype$, ByVal sort_direction$) As DataTable
Dim dv As DataView
Dim dt2 As DataTable
dt2 = dt.Clone
dt2.Merge(dt)
dv = dt2.DefaultView
dv.Sort = sorttype & " " & sort_direction
Return dv.ToTable()
End Function
推荐答案
,ByVal sort_direction
, ByVal sort_direction
)作为DataTable Dim dv作为DataView Dim dt2作为数据表 dt2 = dt.Clone dt2.Merge(dt) dv = dt2.DefaultView dv.Sort = sorttype& "& sort_direction 返回dv.ToTable() 结束功能
) As DataTable Dim dv As DataView Dim dt2 As DataTable dt2 = dt.Clone dt2.Merge(dt) dv = dt2.DefaultView dv.Sort = sorttype & " " & sort_direction Return dv.ToTable() End Function
您可以直接在数据视图中使用数据表"dt".
为什么要摆弄另一个本地作用域表"dt2"?浪费资源和时间!
You could have directly use the datatable ''dt'' with Dataview.
Why toying around with another local scope table ''dt2''? Waste of resources and time!
这篇关于排序功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文