排序数据表 [英] sort data table
本文介绍了排序数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友们,
我正在使用以下代码对表进行排序并将其保存为原始数据格式.我不希望表格仅按视图排序.我想按升序存储它.
Hi friends,
I am using the following code to sort and save the table on the raw data format. I don''t want the table to sort for view only. I want to store it in ascending order.
dSListofDrugs.Tables[0].DefaultView.Sort = "[Drugs] " + "asc";
这对我不起作用.
感谢您的帮助.
this don''t work for me.
Thanks for the help.
推荐答案
使用DataTable.Select
的此重载.
请参阅 http://msdn.microsoft.com/en-us/library/way3dy9w.aspx [^ ]
这将给出一个排序后的DataRow
s数组,您可以从中创建一个新的数据表.
Use this overload ofDataTable.Select
.
See http://msdn.microsoft.com/en-us/library/way3dy9w.aspx[^]
That will give a sorted array ofDataRow
s, from which you can create a new data table.
您可能想看看DataView.Sort
请参阅 http://msdn.microsoft.com/en-us/library/69c06922(v = vs.71).aspx
You might want to look at theDataView.Sort
See http://msdn.microsoft.com/en-us/library/69c06922(v=vs.71).aspx
这篇关于排序数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文