In the next step we will need to modify our Recordset to accommodate the sorting feature:
1. Double click the Recordset name in the Server Behaviors panel to open the dialog box.
2. Click the “+” button in the variables section to add a new variable.
Enter “SortColumn” for the Name, “TITLE” for the Default value (remember we want the datagrid sorted by TITLE when the page first loads) and “$_GET['SortColumn']” for the Runtime value:
This will sort the datagrid by “TITLE” unless the user selects a different column by submitting a form with SortColumn field set to a value other than “TITLE”.
Click OK to insert the variable.
Create another variable with the following parameters:
Name: SortOrder
Default value: ASC
Runtime value: $_GET[‘SortOrder’]
This will set the sort order to ascending unless the user changes it by submitting a form with SortOrder field set to “DESC” (descending).