Databases Reference
In-Depth Information
can take advantage of the Text filter template created in Chapter 5 to create a filter control
for the ProductName property of the Product entity:
<asp:DynamicFilter runat=”server” DataField=”ProductName”
FilterUIHint=”Text ”/>
You also want to be able to specify custom attributes in page markup and access them in
the filter template. For instance, when configuring the ProductName filter, you might
need to make the TextBox control wider and allow users to see longer values without
scrolling. In page markup, you would want to write something like this:
<asp:DynamicFilter runat=”server” DataField=”ProductName”
FilterUIHint=”Text” Columns=”100” />
In the Text filter template, you would want to define a public property called Columns and
use it to initialize the TextBox the template creates, like so:
public partial class TextFilter
{
public int Columns { get; set; }
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (this.Columns > 0)
this.textBox.Columns = this.Columns;
}
}
Unfortunately, the DynamicFilter control does not support use of custom attributes to
initialize public properties of the filter templates. So if you wanted to provide the ability
to change the size of the TextBox control in the Text filter template from a custom page,
you couldn't simply specify it in the page markup as just shown. Instead, you would have
to stick it in the FilterUIHintAttribute applied to the property in the entity model and
add code to the filter template to retrieve it dynamically. This is not only more cumber-
some, it also forces you to place presentation logic of a specific page in the entity model.
Consider the Parent field template that displays values of properties from a related entity.
This template uses a DynamicControl (yes, an UnleashedControl in this example, which is
not important for this discussion) to locate and instantiate another field template. A
similar filter template could allow you to build search pages based on columns from
related entities. Perhaps you need to create a page where users can search for Products by
the Country of their Suppliers. Here is how you would want to use this filter template in
page markup:
<asp:DynamicFilter runat=”server” DataField=”Supplier”
FilterUIHint=”Parent” DisplayField=”Country” />
 
Search WWH ::




Custom Search