Click here to Skip to main content
15,886,864 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted

Try this

DataView dataview = yourdatatable.DefaultView;
dataview.Sort = "ColumName";
DataTable dt = dataview .ToTable();
 
Share this answer
 
v2
Comments
FarhanShariff 5-Mar-14 12:02pm    
No it is sorting in inverse order -ve sign not considered
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900