[Solved] Asp.net: Sorting with gridview and objectDataSource [closed]


Here is a question that has been previously answered.

For the actual sorting, you would call

collectionOfObjects.OrderBy(x => x.PropertyToSortOn);

You could use a switch to change what to sort on based on what is passed into the method via the args. So it would look a little more like this

switch(propertyName)
{
  case "property1":
    collectionOfObjects.OrderBy(x => x.PropertyToSortOn);
    break;
  case "property2":
    collectionOfObjects.OrderBy(x => x.OtherPropertyToSortOn);
    break;

  ...

}

Hope this helps! 🙂

8

solved Asp.net: Sorting with gridview and objectDataSource [closed]