Sort a gridview
Posted on 2014-02-24
I have a gridview that sources its data from various sources..
The first two columns, Username and a date, are populated from a query that is coded inline...
Then, in the rowDataBound event for the gridview, I grab the username and perform further queries/Calculations using this username as a key to provide information I populate the rest of the columns with... (by modifying template fields in the gridview that hold label controls).
This all works fine, but I now am thinking that I might like to be able to sort this gridview on some of the fields that aren't populated by the inline query...
So, I was thinking that all I needed to do was pull the data out of the gridview into some sort of list or array, sort it there, then re-populate the gridview from this list/array...
Is this the right way to do this, or am I missing something obvious??
The issue is that the fields in the gridview aren't populated from the same query (and can't be), but I need a way of sorting the data and re-populating the gridview should the user wish to..
Any help would be appreciated..
thanks in advance..