使用负值对字符串类型DataTable C#进行排序 [英] Sorting String type DataTable C# with Negative values
本文介绍了使用负值对字符串类型DataTable C#进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有dataTable,类型为 string
我想将它从最小到最大的一列排序有-ve值,其他有正面,有些有+ ve和-ve值大约有2000列
如何将DataTable从字符串类型转换为十进制类型,以便对值进行排序
I have dataTable which is of type string
I want to sort it from smallest to largest one column has -ve values and other has positive and some have +ve and -ve values there are around 2000 columns
How to convert the DataTable from string type to decimal type so as to sort the values
推荐答案
试试这个
DataView dataview = yourdatatable.DefaultView;
dataview.Sort =ColumName;
DataTable dt = dataview .ToTable();
Try this
DataView dataview = yourdatatable.DefaultView;
dataview.Sort = "ColumName";
DataTable dt = dataview .ToTable();
检查以下网址以获取多种解决方案。
如何更改DataTable中DataColumn的DataType? [ ^ ]
一个解决方案可以也可以使用Typed Data表。搜索谷歌了解更多详情
Check below url for multiple solutions.
How To Change DataType of a DataColumn in a DataTable?[^]
One solution could also be to use Typed Data table. Search google for more details
这篇关于使用负值对字符串类型DataTable C#进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文