Sort by two columns in grid

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
 
E

Eliyahu Goldin

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
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top