10.2. Design

Figure 10-1 shows a screen shot of the query builder control that we are going to create.

Figure 10.1. Figure 10-1

The first control is a drop-down list of all the fields the user can query by. The second drop-down list contains a list of comparison operators such as Equals, Not Equals, Is In List, Is Not In List, Greater Than, Greater Than or Equal To, Less Than, Less Than Or Equal To, Is Blank, and Is Not Blank. The comparison operators are converted into syntax that the database understands. For example, Not Equals converts to <> and Is Blank converts to Is NULL. The third drop-down list contains the list of data that is in the Select a Field drop-down list. If the comparison operator is "Is In List" or "Is Not In List," then this is displayed as a list box. You populate the data in this list by making an ASP.NET AJAX call back to the server after the user has selected the field and comparison.

This gets a little tricky because when the screen posts back, it can take some time to fill the list. Therefore, a "Please Wait" modal dialog is displayed while the processing is occurring on the server. The modal dialog is an extender control that can be found in the ASP.NET AJAX Control Toolkit, which can be downloaded free at www.codeplex.com/AjaxControlToolkit/Release/ProjectReleases.aspx?ReleaseId=16488. The buttons after the drop-down lists are used to add the filter ...

Get ASP.NET 3.5 Enterprise Application Development with Visual Studio® 2008: Problem - Design - Solution now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.