TechTalk Genome v4.2

TemplateQueryField Class

Represents a query field that displays custom content and performs custom filter logic in a QueryForm control.

For a list of all members of this type, see TemplateQueryField Members.

System.Object
   QueryField
      TemplateQueryField

public class TemplateQueryField : QueryField

Remarks

The TemplateQueryField is a QueryField implementation which allows custom controls to be displayed and corresponding custom filter logic to be performed. Use the TemplateQueryField class to create custom user interfaces (UI) and apply your custom filter logic when you need to display content in a QueryForm control or you have to perform filter logic that is not provided by one of the predefined query fields.

Specify the FilterTypeName property to define the custom IQueryFilter implementation applied by the TemplateQueryField. The specified IQueryFilter implementation must have a public default constructor. When the TemplateQueryForm extracts filter criteria, it creates the specified type of filter with the default constructor.

You can define a custom template by using the ItemTemplate property that will be rendered as content of the TemplateQueryField. You can use data-binding expressions in the template to bind properties of the controls to properties of the custom filter implementation. Since it is important to extract the filter properties from the controls, use the Bind method to define two-way data-binding expressions. The properties of the filter implementation must be publicly gettable and settable to successfully bind them to the controls with two-way data-binding.

Additional "parameters" of the filter can be specified with the Parameters property. The corresponding filter property (specified by the name of the parameter) will be set with the value of the parameter when extracting the filter. The matching properties of the filter must be publicly settable.

Example

In the following sample, the QueryForm filters a data source that contains Customer objects. The first query field is a LikeQueryField which renders a TextBox and internally builds a QueryLikeFilter filter for the CompanyName property with the text from the text box. The second field is a TemplateQueryField which provides exactly the same functionality with custom templates.

          
            <genomeControls:QueryForm ID="CustomerQueryForm" runat="server" GenomeDataSourceID="CustomerDataSource" OnCommand="CustomerQueryForm_Command">
                <Fields>
                    <genomeControls:LikeQueryField PropertyName="CompanyName" HeaderText="Company Name" />
                    
                    <genomeControls:TemplateQueryField HeaderText="Company Name (with template field)" FilterTypeName="TechTalk.Genome.Extensions.Web.UI.Controls.QueryLikeFilter">
                        <Parameters>
                            <asp:Parameter Name="PropertyName" DefaultValue="CompanyName" />
                        </Parameters>
                        <ItemTemplate>
                            <asp:TextBox ID="tb" runat="server" Text='<%# Bind("Value") %>' />
                        </ItemTemplate>
                    </genomeControls:TemplateQueryField>
                </Fields>
            </genomeControls:QueryForm>

        

Requirements

Namespace: TechTalk.Genome.Extensions.Web.UI.Controls

Assembly: TechTalk.Genome.Extensions.Web (in TechTalk.Genome.Extensions.Web.dll)

Version: 4.2.4.4

Editions: Professional, Evaluation, Express

See Also

TemplateQueryField Members | TechTalk.Genome.Extensions.Web.UI.Controls Namespace