RDS 2.5 API Reference

FilterColumn, FilterCriterion, FilterValue, SortColumn, and SortDirection Properties and Reset Method Example (VBScript)

The following code shows how to set the RDS.DataControl Server parameter at design time and bind it to a data-aware HTML table using a data source. Cut and paste the following code to Notepad or another text editor and save it as FilterColumnVBS.asp.

<!-- BeginFilterColumnVBS -->

<%@ Language=VBScript %>

<HTML>

<HEAD>

<META name="VI60_DefaultClientScript" Content="VBScript">

<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">

<TITLE>FilterColumn, FilterCriterion, FilterValue, SortColumn, and SortDirection

Properties and Reset Method Example (VBScript)</TITLE>

</HEAD>

<BODY>

<h1>FilterColumn, FilterCriterion, FilterValue, SortColumn, and SortDirection

Properties and Reset Method Example (VBScript)</h1>

<OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" ID=RDS HEIGHT=1 WIDTH=1>

<PARAM NAME="SQL" VALUE="Select FirstName, LastName, Title, ReportsTo, Extension from Employees">

<PARAM NAME="Connect" VALUE="Provider='sqloledb';Data Source=<%=Request.ServerVariables("SERVER_NAME")%>;Integrated Security='SSPI';Initial Catalog='Northwind'">

<PARAM NAME="Server" VALUE="http://<%=Request.ServerVariables("SERVER_NAME")%>">

</OBJECT>

Sort Column: <SELECT NAME="cboSortColumn">

<OPTION VALUE=""></OPTION>

<OPTION VALUE=ID>ID</OPTION>

<OPTION VALUE=FirstName>FirstName</OPTION>

<OPTION VALUE=LastName>LastName</OPTION>

<OPTION VALUE=Title>Title</OPTION>

<OPTION VALUE=Title>ReportsTo</OPTION>

<OPTION VALUE=Phone>Extension</OPTION>

</SELECT>

<br>

Sort Direction: <SELECT NAME="cboSortDir">

<OPTION VALUE=""></OPTION>

<OPTION VALUE=TRUE>Ascending</OPTION>

<OPTION VALUE=FALSE>Descending</OPTION>

</SELECT>

<HR WIDTH="25%">

Filter Column: <SELECT NAME="cboFilterColumn">

<OPTION VALUE=""></OPTION>

<OPTION VALUE=FirstName>FirstName</OPTION>

<OPTION VALUE=LastName>LastName</OPTION>

<OPTION VALUE=Title>Title</OPTION>

<OPTION VALUE=Room>ReportsTo</OPTION>

<OPTION VALUE=Phone>Extension</OPTION>

</SELECT>

<br>

Filter Criterion: <SELECT NAME="cboCriterion">

<OPTION VALUE=""></OPTION>

<OPTION VALUE="=">=</OPTION>

<OPTION VALUE="&gt;">&gt;</OPTION>

<OPTION VALUE="&lt;">&lt;</OPTION>

<OPTION VALUE="&gt;=">&gt;=</OPTION>

<OPTION VALUE="&lt;=">&lt;=</OPTION>

<OPTION VALUE="&lt;&gt;">&lt;&gt;</OPTION>

</SELECT>

<br>

Filter Value: <INPUT NAME="txtFilterValue">

<HR WIDTH="25%">

<INPUT TYPE=BUTTON NAME=Clear VALUE="CLEAR ALL"> &nbsp;

<INPUT TYPE=BUTTON NAME=SortFilter VALUE="APPLY">

<HR>

<TABLE DATASRC=#RDS ID="DataTable">

<THEAD>

<TR>

<TH>FirstName</TH>

<TH>LastName</TH>

<TH>Title</TH>

<TH>Reports To</TH>

<TH>Extension</TH>

</TR>

</THEAD>

<TBODY>

<TR>

<TD><SPAN DATAFLD="FirstName"></SPAN></TD>

<TD><SPAN DATAFLD="LastName"></SPAN></TD>

<TD><SPAN DATAFLD="Title"></SPAN></TD>

<TD><SPAN DATAFLD="ReportsTo"></SPAN></TD>

<TD><SPAN DATAFLD="Extension"></SPAN></TD>

</TR>

</TBODY>

</TABLE>

<Script Language="VBScript">

<!--

Const adFilterNone = 0

Sub SortFilter_OnClick

Dim vCriterion

Dim vSortDir

Dim vSortCol

Dim vFilterCol

' The value of SortColumn will be the

' value of what the user picks in the

' cboSortColumn box.

vSortCol = cboSortColumn.options(cboSortColumn.selectedIndex).value

If(vSortCol <> "") then

RDS.SortColumn = vSortCol

End If

' The value of SortDirection will be the

' value of what the user specifies in the

' cboSortdirection box.

If (vSortCol <> "") then

vSortDir = cboSortDir.options(cboSortDir.selectedIndex).value

If (vSortDir = "") then

MsgBox "You must select a direction for the sort."

Exit Sub

Else

If vSortDir = "Ascending" Then vSortDir = "TRUE"

If vSortDir = "Descending" Then vSortDir = "FALSE"

RDS.SortDirection = vSortDir

End If

End If

' The value of FilterColumn will be the

' value of what the user specifies in the

' cboFilterColumn box.

vFilterCol = cboFilterColumn.options(cboFilterColumn.selectedIndex).value

If(vFilterCol <> "") then

RDS.FilterColumn = vFilterCol

End If

' The value of FilterCriterion will be the

' text value of what the user specifies in the

' cboCriterion box.

vCriterion = cboCriterion.options(cboCriterion.selectedIndex).value

If (vCriterion <> "") Then

RDS.FilterCriterion = vCriterion

End If

' txtFilterValue is a rich text box

' control. The value of FilterValue will be the

' text value of what the user specifies in the

' txtFilterValue box.

If (txtFilterValue.value <> "") Then

RDS.FilterValue = txtFilterValue.value

End If

' Execute the sort and filter on a client-side

' Recordset based on the specified sort and filter

' properties. Calling Reset refreshes the result set

' that is displayed in the data-bound controls to

' display the filtered, sorted recordset.

RDS.Reset

End Sub

Sub Clear_onClick()

'clear the HTML input controls

cboSortColumn.selectedIndex = 0

cboSortDir.selectedIndex = 0

cboFilterColumn.selectedIndex = 0

cboCriterion.selectedIndex = 0

txtFilterValue.value = ""

'clear the filter

RDS.FilterCriterion = ""

RDS.Reset(FALSE)

End Sub

-->

</Script>

</BODY>

</HTML>

<!-- EndFilterColumnVBS -->

See Also

DataControl Object (RDS) | FilterColumn Property (RDS) | FilterCriterion Property (RDS) | FilterValue Property (RDS) | Reset Method (RDS) | SortColumn Property (RDS) | SortDirection Property (RDS)

© 1998-2003 Microsoft Corporation. All rights reserved.