View Single Post
  #7 (permalink)  
Old July 27th, 2008, 11:58 PM
Lee Dumond's Avatar
Lee Dumond Lee Dumond is offline
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

I understood exactly what Imar was saying. In fact, Imar and Pedant are both saying the same exact thing -- you should both sort and page on the database server. Forget about doing both sorting and paging at the same time in the ObjectDataSource.

Write SQL that implements a dynamic query for sorting. Then write a SPROC that grabs a page of records, based on the ObjectDataSource's startRowIndex and maximumRows (converting startRowIndex to page index, as I pointed out before.)

Whenever the sort changes, rerun the dynamic query, then grab a new page of records STARTING AT THE FIRST RECORD, then rebind the Gridview.

Say, for example, the client Gridview is showing Customer names (Name) and the amount of stuff they've purchased (Purchases). You have the GridView sorted by Name. The client pages, pages, pages through the records. Then, the client clicks on the row heading to sort by Purchases. The GridView rebinds and starts showing the FIRST page of records of this sort. The lowest purchase is right on top, without regard to where the client was when the GridView was re-sorted.

Make sense?