DataTable: Sort by multiple columns.

H

Hetal

Hi...

We are on Visual Basic .NET 2003 and i am using DataView to sort the
DataTable. However, we are facing problems with sorting the data based
on multiple columns.

The below statement to sort the table based on 1 column works
perfectly fine.

dvShiftData is a DataView
dsScheduleData is a DataSet

dvShiftData =
dsScheduleData.Tables("ShiftData").DefaultView.Sort("bytDay Asc")

But, when we try to sort that table based on 3 columns, it does not
allow us to do so.

dvShiftData =
dsScheduleData.Tables("ShiftData").DefaultView.Sort("bytDay Asc", "Job
Position Asc", "bytHour Asc")

Is there a way we can sort a DataTable based on multiple columns?

Thanks,
Hetal.
 
O

\(O\)enone

Hetal said:
But, when we try to sort that table based on 3 columns, it does not
allow us to do so.

dvShiftData =
dsScheduleData.Tables("ShiftData").DefaultView.Sort("bytDay Asc", "Job
Position Asc", "bytHour Asc")

Have you tried:

\\\
dsScheduleData.Tables("ShiftData").DefaultView.Sort("bytDay Asc, Job
Position Asc, bytHour Asc")
///

(i.e., pass all three columns in a single string, separated by commas).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top