You can sort and filter a recordset using the AdvancedDataControl sort and filter properties and methods. Sorting orders the records in the recordset in a specific order (for example, by first name or invoice number), and filtering restricts the result set of records that meet some criteria (for example, employee records whose title is manager).
Tip When you already know how you want to sort and filter your data, it's faster to sort and filter the recordset by using an SQL string that uses an ORDER BY and WHERE clause.
You can set the SortColumn and SortDirection properties of the AdvancedDataControl object, and then call the Reset method to sort the recordset on the client-side cache and refresh the resultset that is displayed in the data-bound controls. The Reset method will execute the criteria and replace the current recordset with a read-only recordset.
The following example shows how to sort a recordset ordered according to the specified column in ascending order:
<Pre>Sort Column <INPUT Name="txtSortColumn" Size=30> </PRE> <INPUT Type=Button Name="btnSort" Value = "Sort" Sub btnSort_OnClick If (txtSortColumn.Text <> "") Then ADC1.SortColumn = txtSortColumn.Text End If ' Execute the sort. ADC1.Reset End Sub
You can use the FilterValue, FilterCriterion, and FilterColumn properties of the AdvancedDataControl object, and then call the Reset method to filter a recordset on the client-side cache and refresh the resultset that is displayed in the data-bound controls. Again, the Reset method will execute the criteria and replace the current recordset with a read-only recordset.
<Pre>Filter Column <INPUT Name="txtFilterColumn" Size=30> </PRE> <Pre>Operator <INPUT Name="txtCriterion" Size=4> </PRE> <Pre>Filter Value <INPUT Name="txtFilterValue" Size=30> </PRE> <INPUT Type=Button Name="btnFilter" Value = "Filter" Sub btnFilter_OnClick If (txtFiltercolumn.Text <> "") Then ADC1.FilterColumn = txtFiltercolumn.Text End If If (txtCriterion.Text <> "") Then ADC1.FilterCriterion = txtCriterion.Text End If If (txtFilterValue.Text <> "") Then ADC1.FilterValue = txtFilterValue.Text End If ' Execute the filter. ADC1.Reset End Sub
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.