Sql – a ListView, a LinqDataSource, linq-to-sql and ordering

asp.netlinqlinq-to-sql

So I'm writing a page which does some reporting and it's pretty dynamic, the user has the ability to group data and sort columns. I've been able to get my dynamic grouping down and then the sorting except now my generated linq-to-sql sql order by statement is backwards from what I want it to be. I think I need to figure out how to get at the Result returned from the LinqDataSource when the Sorting event is fired in the ListView so that I can then append my grouping order by clauses.

Currently I'm overriding the LinqDataSource selecting event to provide it's result and do the dynamic grouping there, but then the Result is modified by the Sort on the listview and I was thinking there must be some way to get at that result during the Sorting or Sorted event.

Any insight would be appreciated, in the meantime I will be attempting to figure this out myself.

Best Answer

Awesome I think I found my answer, set AutoSort to false on my LinqDataSource and then sort the data myself, since I'm already sorting myself for the other data.