This documentation is archived and is not being maintained.

FilterRepeater Class

Represents a control that enumerates table columns that can be filtered.

Namespace:  System.Web.DynamicData
Assembly:  System.Web.DynamicData (in System.Web.DynamicData.dll)

[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class FilterRepeater : Repeater, 
	IWhereParametersProvider
<asp:FilterRepeater />

The FilterRepeater control is a control in the ASP.NET Dynamic Data framework. It automatically renders controls that can be used to filter data rows that are displayed for a table. The filters work by providing a list of Where parameters to the data source for each supported column type. By default, Dynamic Data filters foreign-key and Boolean columns and renders them by using a DropDownList list control.

The FilterRepeater control is a specialized Repeater control that automatically binds to a collection of filterable columns for the table that is displayed in the current page. For example, if a request is made for /Products/List.aspx, the FilterRepeater control binds to the columns in the Products table. The table is chosen based on the route that matches the request. It can also be overridden by setting the TableName and ContextTypeName properties of the FilterRepeater control.

To display the filter UI, the ItemTemplate template of the FilterRepeater control must contain a control with a known ID. By default, the known ID is "DynamicFilter". The control in the item template must derive from FilterUserControlBase. When data binding occurs, the FilterRepeater control initializes an instance of the filter control with information about the column to filter.

The following example shows how the ControlId property of the DynamicControlParameter object is set to the ID of the FilterRepeater control.

<%@ Page Language="C#" MasterPageFile="~/Site.master" %>

<%@ Register Src="FilterUserControl.ascx" TagName="DynamicFilter" TagPrefix="asp" %>

<script runat="server">

    protected MetaTable table;

    protected void Page_Init(object sender, EventArgs e) {
        DynamicDataManager1.RegisterControl(GridView1);

    }

    protected void Page_Load(object sender, EventArgs e) {
        table = GridDataSource.GetTable();

        if (table.IsReadOnly) {
            GridView1.Columns.RemoveAt(0);
        }
    }

    protected void OnFilterSelectedIndexChanged(object sender, EventArgs e) {
        GridView1.PageIndex = 0;
    }

</script>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:DynamicDataManager ID="DynamicDataManager1" runat="server" 
        AutoLoadForeignKeys="true" />

    <asp:FilterRepeater ID="FilterRepeater" runat="server">
        <ItemTemplate>
            <asp:Label ID="Label1" runat="server" Text='<%# Eval("DisplayName") %>' AssociatedControlID="DynamicFilter$DropDownList1" />
            <asp:DynamicFilter runat="server" ID="DynamicFilter" OnSelectedIndexChanged="OnFilterSelectedIndexChanged" />
        </ItemTemplate>
    </asp:FilterRepeater>

    <asp:GridView ID="GridView1" runat="server" DataSourceID="GridDataSource" AllowPaging="True"
        AllowSorting="True" CssClass="gridview">
    </asp:GridView>

    <asp:LinqDataSource ID="GridDataSource" runat="server" EnableDelete="true">
        <WhereParameters>
            <asp:DynamicControlParameter ControlId="FilterRepeater" />
        </WhereParameters>
    </asp:LinqDataSource>

</asp:Content>

System.Object
  System.Web.UI.Control
    System.Web.UI.WebControls.Repeater
      System.Web.DynamicData.FilterRepeater

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5 SP1
Show: