archcommus
Diamond Member
Hey guys,
I have a C# web application I'm working on. I have a GridView object where each row is an object (class) I've made with various properties. I know I can have the object implement IComparable, write a CompareTo function in the class, and then sort an array of this object using Array.Sort(), but I want to be able to sort the object on different properties, for example name, or type, or date, so that users can the use the column headers in the GridView to sort. I've read a number of different ways to go about this, some using private internal sorting classes and then IComparer, others using refraction and such. Which method would you recommend?
Thanks.
I have a C# web application I'm working on. I have a GridView object where each row is an object (class) I've made with various properties. I know I can have the object implement IComparable, write a CompareTo function in the class, and then sort an array of this object using Array.Sort(), but I want to be able to sort the object on different properties, for example name, or type, or date, so that users can the use the column headers in the GridView to sort. I've read a number of different ways to go about this, some using private internal sorting classes and then IComparer, others using refraction and such. Which method would you recommend?
Thanks.