MDAC 2.5 SDK - ADO


 

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

See Also

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.

<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
   ID=RDS HEIGHT=1 WIDTH=1>
   <PARAM NAME="SQL" VALUE="Select * from Employee">
   <PARAM NAME="SERVER" VALUE="http://<%=Request.ServerVariables("SERVER_NAME")%>">
   <PARAM NAME="CONNECT" VALUE="Provider=SQLOLEDB;User Id=rdsdemo;Password=rdsdemo;Initial Catalog=AddrBookDB">
</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=Type>Type</OPTION>
                  <OPTION VALUE=Email>Email</OPTION>
                  <OPTION VALUE=Building>Building</OPTION>
                  <OPTION VALUE=Room>Room</OPTION>
                  <OPTION VALUE=Phone>Phone</OPTION>
             </SELECT>
             <br>
Sort Direction: <SELECT NAME="cboSortDir"> 
              <OPTION VALUE=""></OPTION>
                  <OPTION VALUE=TRUE>TRUE</OPTION>
                  <OPTION VALUE=FALSE>FALSE</OPTION>
                </SELECT>
<HR WIDTH="25%">
Filter Column: <SELECT NAME="cboFilterColumn"> 
              <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=Type>Type</OPTION>
                  <OPTION VALUE=Email>Email</OPTION>
                  <OPTION VALUE=Building>Building</OPTION>
                  <OPTION VALUE=Room>Room</OPTION>
                  <OPTION VALUE=Phone>Phone</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>ID</TH>
    <TH>FirstName</TH>
    <TH>LastName</TH>
    <TH>Title</TH>
    <TH>Type</TH>
    <TH>Email</TH>
    <TH>Building</TH>
    <TH>Room</TH>
    <TH>Phone</TH>
  </TR>
</THEAD>
<TBODY>
  <TR>
    <TD><SPAN DATAFLD="ID"></SPAN></TD>
    <TD><SPAN DATAFLD="FirstName"></SPAN></TD>
    <TD><SPAN DATAFLD="LastName"></SPAN></TD>
    <TD><SPAN DATAFLD="Title"></SPAN></TD>
    <TD><SPAN DATAFLD="Type"></SPAN></TD>
    <TD><SPAN DATAFLD="Email"></SPAN></TD>
    <TD><SPAN DATAFLD="Building"></SPAN></TD>
    <TD><SPAN DATAFLD="Room"></SPAN></TD>
    <TD><SPAN DATAFLD="Phone"></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 "True or False are only acceptable Sort Direction values."
         Exit Sub
      Else
         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>