Last post Mar 22, 2011 03:13 PM by isatemple
Oct 04, 2007 12:33 PM|jchapman123|LINK
I have a ObjectDataSource attached to a gridview and would like to do natural sorting on only certain columns.
The gridview also generates is columns dynamicly based data from a database.
Where I believe I am getting confused is where I should do my sorting? gridview_OnSorting()?, ObjectDataSource.SortParameterName = "whatever", or at my object level Person.CompareTo()?
I have an IComparer that will do a natural sort, but it's only in 1 direction, and it seems I have to specify every possible column and sortDirection in a switch statement.
Is there an easy way to do this? Including a way to do natural sorting?
Oct 08, 2007 09:56 PM|Nai-Dong Jin - MSFT|LINK
How to handle with your sorting, it's related to the data type you returned from your method in business object class. If what you
return is something like DataTable (or DataSet), then you can achieve your goal by using SortExpression property since DataTables have sorting abilities built-in. But if you pass it in any other type of object, it should be converted into an IEnumerable object,
they are required to use the SortParameterName of the ObjectDataSource.
You may refer the following link:
This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft
does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent
dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
Oct 09, 2007 09:46 AM|jchapman123|LINK
Works like a champ!
Mar 22, 2011 03:13 PM|isatemple|LINK
So, I am not sure which direction to go based on these links. I have a GridView pulling from a TableAdapter, and I simply wish to do a natural sort on the first column, solve the problem of (z1, z10, z2, z3, z4...). There must be an easier way to do this
without all the custom coding, no? Can I point a SortExpression to the popular Dave Koelle algorithm C# class?