Databases Reference
In-Depth Information
DynamicFilterExpression
passes the query to its
DynamicFilter
, which in turn passes it
to its filter template,
Text.ascx
, in this example.
Figure 5.2 illustrates how the whole process works, starting with the
EntityDataSource
on
the left and ending with the filter template, a
QueryableFilterUserControl
, on the right.
FIGURE 5.2
Query modification sequence diagram.
It might seem this markup is more complex than the original version shown in Listing
5.1. However, keep in mind, unlike in the original page where there was a significant
amount of data access logic hard-coded in the code-behind file, the new page has most of
this logic in the markup, leaving the code-behind (see Listing 5.6) almost empty.
Implementing filtering for additional columns is also easier. Should you need to support
filtering for additional columns on this page, you can simply add more
DynamicFilter
controls to the markup without having to modify the code-behind.
LISTING 5.6
Sample Search Page with DynamicFilter Controls (Code-Behind)
using System;
using System.Web.DynamicData;
namespace WebApplication.Samples.Ch05.DynamicFilter
{
public partial class SamplePage : System.Web.UI.Page
{
protected void Page_Init(object sender, EventArgs e)
{
MetaTable table = Global.DefaultModel.GetTable(“Customers”);
this.gridView.SetMetaTable(table);
}
}
}