Searching with only one search parameter (ASP.NET)

Searching with only one search parameter (ASP.NET)

When the user clicks the page’s Search button, the search parameter is sent to the server. The server processes the request, builds a filtered DataSet based on the parameter, populates a DataGrid, and sends the page back to the browser.

Before adding the DataGrid, you must define a DataSet that finds and stores all the records that meet the search criteria.

To create a DataSet to hold the search results:

  1. In the Bindings panel (Window > Bindings), click the Plus (+) button and select DataSet (Query).

    If the advanced dialog box appears, click the Simple button to open the simple dialog box.

  2. Name the DataSet, and then select a connection and database table containing the data you want users to search.
  3. In the Columns area, click the Selected option and select a key column (usually the record ID column) and the columns containing the data you want to display in the DataGrid.

Leave the DataSet dialog box open for now. You’ll use it next to retrieve the search parameters sent to the server and create a DataSet filter to exclude records that don’t meet the parameters.

To create a DataSet filter:

  1. From the first pop-up menu in the Filter area, select a column in the table to compare against the search parameter sent by the search page.

    For example, if the value sent by the search page is a city name, select the column in your table that contains city names.

  2. From the pop-up menu beside the first menu, select the equal sign (it should be the default).

    This choice states that the user wants only those records in which the selected table column is exactly the same as the one specified on the search page. You can use a less restrictive option such as "begins with" or "contains."

  3. From the third pop-up menu, select Form Variable.

    The parameter is sent to the server by a form using the POST method.

  4. In the fourth text box, enter the name of the form control that sent the search parameter to the server.

    You can get the name by clicking the form control on the form to select it, and checking the control’s ID in the Property inspector.

  5. If you want, click Test, enter a test value, and click OK to connect to the database and create an instance of the DataSet.

    The test value simulates the value that would otherwise have been returned from the search page. Click OK to close the Dataset.

  6. If you’re satisfied with the DataSet, click OK.

Dreamweaver inserts code in your page that, when run on the server, checks each record in the database table. If the specified field in a record meets the filtering condition, the record is included in a DataSet. The code in effect builds a recordset containing only the search results.

The next step in creating the search page is to display the search results in a DataGrid. See Displaying the results in a DataGrid.



Getting Started with Dreamweaver
Dreamweaver Basics
Working with Dreamweaver Sites
Laying Out Pages
Adding Content to Pages
Working with Page Code
Preparing to Build Dynamic Sites
Making Pages Dynamic
Developing Applications Rapidly
Building ColdFusion Applications Rapidly
Building ASP.NET Applications Rapidly
Reference
Building ASP and JSP Applications Rapidly
 
ASPTreeView.com
 
Evaluation has ГХТexpired.
Info...