How to sort a dataTable by specific column?

  • Thread starter Thread starter addict
  • Start date Start date
A

addict

I have a 2 tables merged. After merge, I need to sort the target table
by specifc column. How to do it?
Thanks,
 
Hi addict,

You might use DataView over your table to represent the data in sorted
order.
You can't sort the data in datatable though, since it doesn't make sense.

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

addict said:
I have a 2 tables merged. After merge, I need to sort the target table
by specifc column. How to do it?
Thanks,
 
The fact that it's merged doesn't really matter, because a DataSet doesn't
care how it got to it's current state.

Like Miha mentions, creating a DataView based on the given datatable, and
setting its .Sort Property will do it for you. You can sort on multiple
columns and in different directions. Take a look here
http://www.knowdotnet.com/articles/dataviews1.html
for some examples.

HTH,

Bill
addict said:
I have a 2 tables merged. After merge, I need to sort the target table
by specifc column. How to do it?
Thanks,
 
Back
Top