Sort by two columns in grid

  • Thread starter Thread starter Sehboo
  • Start date Start date
S

Sehboo

I have three columns in grid, name, division and terminal. What I
want is that when I click on name header then I want the grid to sort
by name, but when I click on division then it should sort by division,
and then name. This way, all the poeple in each division will be
sorted in alphabatical order. How do I achieve this? I am on VS2003.

Thanks
 
You can specify both columns in the SortExpression property and override
DataGrid.OnSortCommand method. If only one column name is passed in the Sort
Expression property of the event argument, call the default event handler.
If two columns are passed, implement your own sorting. You may re-populate
the datasource with a modified sql or use a DataView that allows specifying
multiple columns for sorting.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
 
Back
Top