473,394 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

DataTable: Sort by multiple columns.

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.Sor t("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.Sor t("bytDay Asc", "Job
Position Asc", "bytHour Asc")

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

Thanks,
Hetal.

Aug 29 '07 #1
1 21043
Hetal wrote:
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.Sor t("bytDay Asc", "Job
Position Asc", "bytHour Asc")
Have you tried:

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

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

--

(O)enone
Aug 29 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: tomi | last post by:
Hi I have following problem. I have a datatable filled with some data. Each row holds its ID (column named "Row_ID") DataTable dtTable; I have a datagrid to which I assign this datatable....
1
by: reiks | last post by:
I have a datatable . My requirement is to sort the table rows in ascending and descending order basing on the columns which I give it. I've used the following expression ...
3
by: Solel Software | last post by:
Hello, I have a basic question. I have a DataTable of information without a database store (it's only in memory). I am looking to somehow query the DataTable to find out which row(s) satisfy...
3
by: Gene Hubert | last post by:
I'm using DataTable.ImportRow to move data from one datatable to another... Dim dt, dtTarget As DataTable Dim dr As DataRow dt = DirectCast(Me.DataSource, DataTable) dtTarget = dt.Clone...
0
by: Nathan Franklin | last post by:
Hello Guys, I have been trying to work this our for so long, but I just can't seem to find the answer. I am loading a datatable from a an access database using an oledbdataadapter. I then...
1
by: Lyners | last post by:
I am trying to figure out the best way to do this (currently I am having a problem sorting). I have a vb.net program that contains 2 datagrids on a form for the end user. When the user is ready to...
9
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New...
7
by: Doug Bell | last post by:
Hi, I have a DataSet with a DataTable that has a number of duplicate rows (except for one column that has a unique value). Each row has OrderNo, OrderLineNo, etc and there are multiple rows...
3
by: Bimal Kothari | last post by:
private DataTable SortDataTable(DataTable GetDataTable, string sort) { DataTable _NewDataTable = GetDataTable.Clone(); int rowCount = GetDataTable.Rows.Count; DataRow foundRows =...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.