SearchResults.aspx Page

Description:   The SearchResults page displays a list of all products whose names or descriptions match a specified search criteria. 

Implementation Notes:   This page appears when a user clicks the "search" button that appears at the top of most pages in Adventure Works Cycles. The search form itself is not actually part of the page; instead it is part of the Header user control ( _Header.ascx ) that is incorporated into the page.

The ProductsList page logic is encapsulated entirely within its Page_Load  event handler.  This event handler is called when the page is accessed by a browser client. 

Page_Load Event Handler:  The Page_Load event handler obtains the text clause to search the product database using the Params collection of the page's Request  object.  The Params collection contains all query string, form field, cookie, and server variables sent from a client during an HTTP request. This the typical API through which page developers access arguments when doing page to page navigation transfers.

After extracting the text to search for from the URL, the Page_Load event handler creates an instance of the ProductDB class and calls its GetProducts method, passing it the search text. This method internally uses the usp_ProductSearch stored procedure to fetch the product information from the Adventure Works Cycles database.

The product collection is displayed using a templated <asp:DataList> server control.  The DataList server control contains a user-defined ItemTemplate that describes what each item in the list should look like.  The data values returned from the ProductsDB.GetProducts() method are populated into the DataList by setting its Datasource property, and then calling its DataBind()  method.  When DataBind() is called, the DataList will iterate over the DataSource and render a copy ofthe ItemTemplate for each row, populating it data from the row.