DataTable: Sort by multiple columns.

  • Thread starter Thread starter Hetal
  • Start date Start date
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.
 
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).
 
Back
Top