Bidirectional Sorting on Any Column in DataGrid
page 3 of 7
by Pani Baruri & Abhijit Mandrekar
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 25284/ 38

Part 1: Psuedo Logic
  1. Trap sortcommand event of the datagrid control.

 

  1. Read sortexpression property of the event argument.

 

  1. Sort data in grid using current sort expression.

 

  1. Use split function to separate column name (which represents database field name) and sort direction. The first element of an array contains database field name.

 

  1. If sort direction is ASC then new sort direction is DESC and vice versa. Save the new direction into 2nd element of the array.

 

  1. Loop through all columns

            If column’s sort expression matches sort expression returned from event argument then

                        Concatenate first element of an array, space and second element of an array to

build a new sort expression.

                        Assign new sort expression to current column’s sortexpression property.

                        Exit loop

            End If

End Loop

 

Note: In order for this example to work properly write binding SQL query with order by clause with no mention of column names. The column names are appended at run-time to the binding SQL query.

 


View Entire Article

User Comments

Title: Bidirectional Sorting on Any Column in DataGrid   
Name: brian
Date: 2007-08-08 10:39:14 PM
Comment:
thanks a lot.It really very helpful
thumb up

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-03-28 12:16:18 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search