Databases Reference
In-Depth Information
The code-behind only needs to associate the required MetaTable object with the GridView
control. This allows the DynamicFilter controls to locate the MetaColumn objects based on
the column names specified in their DataField properties.
QueryableFilterRepeater Control
The DynamicFilter control is the right choice for implementing filtering functionality if
you need to build a custom search page with specific search criteria. However, if you need
to build an advanced search page where users can search for data using any of the
supported columns or a dynamic search page that can work for different tables, you can
also use the QueryableFilterRepeater control. Listing 5.7 shows how you could modify
the search page to take advantage of it.
LISTING 5.7
Search Page with QueryableFilterRepeater Control (Markup)
<%@ Page Title=”” Language=”C#”
MasterPageFile=”~/Site.master” CodeBehind=”SamplePage.aspx.cs”
Inherits=”WebApplication.Samples.Ch05.QueryableFilterRepeater.SamplePage” %>
<asp:Content ContentPlaceHolderID=”main” runat=”server”>
<asp:QueryableFilterRepeater runat=”server” ID=”filterRepeater”>
<ItemTemplate>
<%# Eval(“DisplayName”) %>:
<asp:DynamicFilter ID=”DynamicFilter” runat=”server” />
</ItemTemplate>
</asp:QueryableFilterRepeater>
<asp:Button runat=”server” Text=”Find” />
<asp:GridView ID=”gridView” runat=”server” DataSourceID=”dataSource” />
<asp:EntityDataSource runat=”server” ID=”dataSource”
ConnectionString=”name=NorthwindEntities”
DefaultContainerName=”NorthwindEntities” EntitySetName=”Customers” />
<asp:QueryExtender runat=”server” TargetControlID=”dataSource”>
<asp:DynamicFilterExpression ControlID=”filterRepeater” />
</asp:QueryExtender>
</asp:Content>
Similar to the regular Repeater control, QueryableFilterRepeater enables you to define a
markup template that it will use to generate filtering controls for each supported column
in the table. Each instance of the ItemTemplate it defines is bound to a MetaColumn object
describing a column that can be filtered by Dynamic Data. This allows you to use ASP.NET
data-binding syntax <%# Eval(“DisplayName”)%> to generate a text label for each column.
Inside of the ItemTemplate , you also need to have a single instance of the DynamicFilter
control that has ID property set to “DynamicFilter”. This allows the
QueryableFilterRepeater to find the DynamicFilter control inside of each ItemTemplate
instance and configure it based on the current MetaColumn ; the QueryableFilterRepeater
will initialize the filter control at run time.
 
Search WWH ::




Custom Search