Cenario:
I have a GridView bound to a DataSource, every column is sortable.
my main query is something like:
select a, b, c, d, e, f from table order by somedate desc
i added a filter form where i can define values to each one of the fields and get the results of a where form. As a result from this, i had to do a custom sorting so that when i sort by a field, i am sorting the filtered query and not the main one.
Now i have to do custom paging, for the same reason, but i don't understand the philosophy of it: I want to guarantee that i can:
filter the results
sort by a column
when i click on page 2, i get page two of the filtered and sorted results
I don't know what i have to do, so i can bind the GV with this. My sorting Method, that is working just fine looks something like:
string condition = GetConditions(); //gets a string like " where a>1 and b>2" depending on the filter the user defines
string query = "select a, b, c, d, e, f from table ";
string direction = (e.SortDirection == SortDirection.Ascending)? "asc": "desc";
string order = " order by " + e.SortExpression + " " + direction;
UtilizadoresDataSource.SelectCommand = query + condition + order;
i've never done custom paging, i am trying:
GetConditions() //no problem here
How can i find out how the GridView is sorted (by what field and sortingorder)?
thank you very much