sorting datafrid columns

robbie_62

Member
Joined
Jan 27, 2003
Messages
18
Location
ireland
hi there

I use a datagrid to display data from my access db,

I have fields such as

first name
surname
address1
address2
address3
address4
home phone
work phone
mobile

etc,etc

I want to display this data in the order of the columns above but when i load the datagrid,it displays the columns in alphabetical order - eg

address1
address2
address3
address4
first name
home phone
mobile
work phone

is there any way to stop the datagrid sorting my columns ???
 
Specify the sorting order desired in your SQL using ORDER BY:

SELECT ... FROM ... ORDER BY first name, surname, etc.

Then set DataGrid.AllowSorting = False.
 
It sorts the columns? Do you have any special code to do this? If your SELECT lists out the columns in the order you want, the grid should "honor" that SELECT. As long as you have:
SELECT first name, surname, address1, address2...
and not
SELECT address1, address2, address3, address4, first name...
you should be Ok.

-Nerseus
 
Back
Top