ASP.NET 2.0: Playing a bit with GridView "Sort Grouping"
I am on bit experiment mood today, so I did a little tryout to see what it requires to add so called "sort grouping" into GridView. E.g when you have tabular data in GridView and you sort it based on some criteria, you'd want to better express those distinct items, based on which the grid is sorted. Here's a few screenshots of what I did, to demonstrate what I mean.
You have a list of people, say having first name, last name and dob, and when it's in default sort based on last name,.grid would show something like
And the same sorted with first name
And with DOB in descending order
It's not very complicated to do. I did it originally for DataGrid in v1.x and then thought to try with gridView. It requires a small bit knowledge of internal control structure of GridView (finding that with experimenting is possible, no unnamed tools necessary ;-) ), and some code. You can download code for this sample from here
Note! I did it the ugly way and all the code in the sample is so far on Page and getting the distinct data (for separator headers) takes its text from BoundField's Cell's Text. In case you'd use Labels etc. in TemplateFields, you'd need to customize it a bit more.
Update! In case you want easier and reusable approach (mine was based on quick tests and then right away posting about it), Agrinei has posted a sample with source codes, and he posted in on comments on this post :