Databases Reference
In-Depth Information
In this chapter, you saw some of the techniques for building custom pages that display
information in tabular format and allow users to search for information by filtering and
sorting the data. You reviewed some of the limitations of the built-in templates and
controls that Dynamic Data provides out of the box and focused on the commonly
requested need to display read-only information from several related tables on a single
page. Unlike displaying data from a single entity, which Dynamic Data does very well, this
type of functionality is not provided out of the box but not difficult to implement.
The
UnleashedFilter
control created in this chapter along with the
UnleashedFilterTemplate
base class for filter templates and the supporting
UnleashedFilterExpression
eliminates the limitations unnecessarily imposed by the
built-in
DynamicFilter
control in version 4.0 of ASP.NET. In particular, by avoiding the
Page
events, the
UnleashedFilter
allows you to create advanced filter templates that use
nested filter controls to generate powerful queries that span multiple related entities.
Similar to the
DynamicControl
, the
UnleashedFilter
also accepts custom attributes and
automatically initializes the matching public properties of the filter template it creates.
Consistently with the extended functionality of the
UnleashedControl
created earlier in
this topic, the
UnleashedFilter
also recognizes control parameters specified in the
FilterUIHintAttribute
that might be applied to the property in the entity model and
uses them to initialize the matching public properties of the filter template as well.
To enable building pages that display and allow filtering by properties from multiple
related entities, a field template and a filter template (both called Parent) were created.
Both templates are designed for use with foreign key navigation properties, like the
Supplier property of the Product entity. In custom pages, you can use these templates
explicitly by setting the
UIHint
or
FilterUIHint
properties of the
UnleashedControl
or
the
UnleashedFilter
controls, respectively. Both templates define a property called
DisplayField
, which specifies the name of the property in the parent entity that you
want to display on the page and, in the case of the Parent filter template, allow users to
filter by.