10.1. Problem

In the Paid Time Off application, Mary liked the My PTO Requests report built in the previous chapter, but then asked for the same data to be displayed in an Outstanding Requests report, a Current Owner report, and an Approved Requests report. The Outstanding Requests report can be considered the same report but with requests that have a status not equal to Approved, Denied, or Cancelled. The Current Owner report displays the same columns but the report is filtered on the current owner of the request. The Approved Requests report displays the same columns but has a filter such that the status of the requests is equal to Approved. Wouldn't it be great if you had a control that you could place on a page that enabled users to build a filter to be applied to the data before it is displayed in an HTML table, report, or export so you wouldn't have to spend time writing the same code over and over again? Well, that is exactly what this chapter is going to build.

This chapter will build a server-side control that enables users to dynamically build a filter for any data, and use AND\OR logic and even predecessor logic. The control will also incorporate ASP.NET AJAX to dynamically populate drop-down lists and list boxes as the user is defining the query. You'll also learn how to create your own custom attributes that can decorate a class to describe the metadata about the class. This is how field names can be displayed as "friendly" names to the user.

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.