Databases Reference
In-Depth Information
LISTING 1.18
QueryExtender and QueryableFilterRepeater Sample (Markup)
<%@ Page Language=”C#”
MasterPageFile=”~/Site.master” CodeBehind=”SamplePage.aspx.cs”
Inherits=”WebApplication.Samples.Ch01.FilterRepeater.SamplePage” %>
<asp:Content ContentPlaceHolderID=”main” runat=”server”>
<asp:QueryableFilterRepeater runat=”server” ID=”filterRepeater”>
<ItemTemplate>
<%# Eval(“DisplayName”) %>:
<asp:DynamicFilter ID=”DynamicFilter” runat=”server” />
<br />
</ItemTemplate>
</asp:QueryableFilterRepeater>
<asp:ValidationSummary runat=”server”/>
<asp:GridView ID=”gridView” runat=”server” DataSourceID=”dataSource”
DataKeyNames=”ProductID” AutoGenerateEditButton=”true”
AllowPaging=”true” AutoGenerateColumns=”true”/>
<asp:EntityDataSource ID=”dataSource” runat=”server”
ConnectionString=”name=NorthwindEntities” EnableUpdate=”true”
DefaultContainerName=”NorthwindEntities” EntitySetName=”Products” />
<asp:QueryExtender runat=”server” TargetControlID=”dataSource”>
<asp:DynamicFilterExpression
ControlID=”filterRepeater”
/>
</asp:QueryExtender>
</asp:Content>
QueryableFilterRepeater
is another control provided by Dynamic Data. It is somewhat
similar to the
EntityTemplate
control used in entity templates. The
QueryableFilterRepeater
control instantiates its
ItemTemplate
for every column in the
MetaTable
that has an appropriate filter template. This example uses a data binding
expression,
<%# Eval(“DisplayName”) %>
, to render the display name of the column and a
DynamicFilter
to render the appropriate filter template. Instead of creating dynamic filter
expressions for the individual dynamic filter controls, the
QueryExtender
is configured
with a single expression pointing to the filter repeater itself. Figure 1.17 shows the result-
ing page.