ASP.NET Dynamic Data – Text filter / Search

I’ve implemented a Filter to apply on text fields in ASP.NET Dynamic Data websites.

To use it: include the code in your project by putting it in the DynamicData\Filters folder. Then apply the filter to the field you want to enable filtering on using the FilterUIHint attribute.


public partial class Category
  class Category_MetaData
    public string Description { get; set; }

You have to manually trigger the application of the query filter by adding a button to the appropriate template. For example, add this to the List.aspx template:

in the code behind for that template:

protected void SearchButton_Click(object sender, EventArgs e)

If you want to see it in action, you can download the full sample code, which is based on the famous Northwind database on SQLExpress.

I got a lot of inspiration and help from msdn and this blog post to get to a decent implementation for this.

Like always I’ve compressed the code using 7-zip. The best compression tool. Ever.

12 thoughts on “ASP.NET Dynamic Data – Text filter / Search”

Leave a Reply

%d bloggers like this: