How sort datatable by multiple columns (actual underlying data)

How can I sort a datatable using multiple columns?  I want to sort the actual UNDERLYING data.
LVL 9
RobertNZanaAsked:
Who is Participating?
 
sunithnairCommented:
Or try like this http://msdn.microsoft.com/en-us/library/a8ycds2f.aspx
Dim v As DataView = dtTracking.DefaultView;
v.Sort="Company, ContactName, TrackingType";
Return v.ToTable(); 

Open in new window

0
 
sunithnairCommented:
like this
    Dim view As DataView = DataTable1.DefaultView
    view.Sort = "State, ZipCode DESC"
 
Then use the view to bind to the grid

Open in new window

0
 
RobertNZanaAuthor Commented:
But does that sort the underlying data?  In my function (that sorts the dataview) I return the datatable...

Dim dv As New DataView(dtTracking, "", "Company, ContactName, TrackingType", DataViewRowState.OriginalRows)
Return dv.Table

But when I bind the datagrid it's not sorted properly.
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
RobertNZanaAuthor Commented:
See code below.  I setup my sort for the dv, but when I start looping thru it (for each) it's not adhering to the sort!

Dim dv As New System.Data.DataView(dtGridview, "", "Company, ContactName, TrackingType", Data.DataViewRowState.OriginalRows)
 
For Each dr As System.Data.DataRow In dv.Table.Rows

Open in new window

0
 
sunithnairCommented:
Why dont you bind the DataView itself as I mentioned in my 1st post?
0
 
RobertNZanaAuthor Commented:
Thanks!!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.