I’ve implemented a Filter to apply on text fields in ASP.NET Dynamic Data<\/a> websites.<\/p>\n To use it: include the code<\/a> 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.<\/p>\n Example:<\/p>\n 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:<\/p>\n in the code behind for that template:<\/p>\n If you want to see it in action, you can download the full sample code<\/a>, which is based on the famous Northwind<\/a> database on SQLExpress.<\/p>\n I got a lot of inspiration and help from msdn<\/a> and this blog post<\/a> to get to a decent implementation for this.<\/p>\n
<\/a><\/p>\n[MetadataType(typeof(Category_MetaData))]\r\npublic partial class Category\r\n{\r\n class Category_MetaData\r\n {\r\n [FilterUIHint(\"TextFilter\")]\r\n public string Description { get; set; }\r\n }\r\n}\r\n<\/pre>\n\r\n
\r\nprotected void SearchButton_Click(object sender, EventArgs e)\r\n{\r\n ((IQueryableDataSource)this.GridDataSource)\r\n .RaiseViewChanged();\r\n}\r\n<\/pre>\n