Databases Reference
In-Depth Information
you see how overcoming the first limitation enables you to create an advanced filter
template that can filter a query of child entities based on properties of their parents.
However, for illustration of the immediate benefits, consider the sample page in Listing
12.6, which shows an example of using the UnleashedFilter control to specify custom
attributes.
LISTING 12.6 Product Search Page with Wide ProductName Filter (Markup)
<%@ Page Title=”” Language=”C#”
MasterPageFile=”~/Site.master” CodeBehind=”SamplePage.aspx.cs”
Inherits=”WebApplication.Samples.Ch12.UnleashedFilter.SamplePage” %>
<asp:Content ContentPlaceHolderID=”main” runat=”server”>
<unl:UnleashedFilter runat=”server” ID=”productNameFilter” FilterUIHint=”Text”
DataField=”ProductName” Columns=”100” />
<asp:GridView runat=”server” ID=”gridView” DataSourceID=”dataSource”
AutoGenerateColumns=”false”>
<Columns>
<unl:UnleashedField DataField=”ProductName”/>
<unl:UnleashedField DataField=”Supplier” HeaderText=”Origin”
UIHint=”Parent” DisplayField=”Country” />
</Columns>
</asp:GridView>
<asp:EntityDataSource runat=”server” ID=”dataSource”
ConnectionString=”name=NorthwindEntities” DefaultContainerName=”NorthwindEntities”
EntitySetName=”Products”/>
<asp:QueryExtender runat=”server” TargetControlID=”dataSource”>
<unl:UnleashedFilterExpression ControlID=”productNameFilter”/>
</asp:QueryExtender>
</asp:Content>
This sample page demonstrates how the UnleashedFilter control enables you to set a
custom attribute Columns for the UnleashedFilter control in page markup and make the
text box generated by the ProductName filter wider. The custom attribute matches the
public property called Columns declared by the Text filter template, and the
UnleashedFilter takes care of initializing it for you. The Text filter template, located in
the DynamicData\Filters folder of the sample web application, has been modified to
inherit from the new UnleashedFilterTemplate . Its OnInit method initializes the Columns
property of the actual TextBox control where the user enters a product name to search.
Figure 12.3 shows how the resulting page looks with the wide ProductName filter text box
above the grid.
 
Search WWH ::




Custom Search