Sorting should be made on all objects - toebens toebens hi,

the scenario you describe is only sorting the result that was returned to the grid.

if you use paging for example the sorting should be done on all data. in your example you would need to get all the objects from the datasource to fill your list else only the result that was shown on the grid is sorted.

for such a case there are client script solutions for sorting a table with javascript, too. i just saw an article in the code project newsletter about using jquery to sort a gridview.

greetings, tobi

Re: Sorting should be made on all objects - Andreas Kranister Andreas Kranister



of course there are different ways to achieve a goal. They all have advantages and disadvantages. I do not want to discuss these philosphical questions, the best solution depends on the project goal.



The solution I provided here is for the case when you do not page the data by sql server statement but on the webserver like the objectdatasource does out of the box. You select all the data, sort it in the data-access-layer and give this sorted data to the objectdatasource where it gets paged.



This behaviour has of course advantages and disadvantages:

Advantages:

1. You can sort the data on properties which are not stored on the database server (e.g. computed properties). Of course you can say that it is possible to use computed columns in the database to sort for them but that means you have to implement business logic in a layer where it shouldn't be and it has to fit perfectly to the way how you calculate the value in the business layer, that's not a good solution.

2. Transparent behaviour independent from the datasource, even from provider

3. Transparent behaviour independent from the implementation of the businessobject



Disadvantages:

1. Ineffective for large datatables on the database server: The whole data is selected each time you sort or change the page, especially when the database server and the webserver don't have a fast connection. This argument may fit in some cases, but I am sure it is a question of architecture and completly dependent on the project.



Greetings, Andreas

