views:

3563

answers:

2

How should I be adding additional search/filter criteria to a Dynamic Data Web Application?

I created a Dynamic Data Web Application using the Northwind database and I am using a custom page for the Employees table (based on the ListDetails.aspx Page Template). I would like to add additional search/filter/where parameters to the Page. By default the where parameters collection is being dynamically created based on the FilterRepeater control, which is also being dynamically created based on the “foreign key” relationships the Employee Table has.

In an attempt to add additional search criteria, I have tied in to the Selecting event of the GridView's LinqDataSource and am trying to add additional items to the WhereParameters collection of the LinqDataSourceSelectEventArgs.

The problem is I can't specify what type of comparison needs to be performed. The WhereParameters collection only accepts a String and an Object, but not how to compare them. What I really would like to be able to do is add to a collection of predicate delegates...

How should I be adding additional search criteria to this page? Through attributes applied to the LINQ To SQL entity (if so, how)? What if the criteria/criterion is not based on the entity itself, how would I add to the search criteria in that case?

Aaron Hoffman

+6  A: 

If you want to add your own criteria to the application that isn't automatically given to you by DD, you'll have to go to DynamicDataFiltering to do that. DynamicData itself doesn't currently support custom filters and searching. It isn't difficult to implement. Josh Heyes did a great job on it.

Come back if that's not quite what you are looking for

EDIT: Also, if you are just intending on doing some further filtering of the displayed data you could write something like this maybe in the Page_Init without Josh's filtering project:

GridDataSource.WhereParameters.Add(new Parameter("it.myColumn", TypeCode.Int32, myValue));

Doing "in" or "contains" is a little more complicated than that, and would require DynamicDataFiltering.

jlembke
I tried following Josh's directions on converting LinqDataSource to a DynamicLinqDataSource but I never get an action as he said “called UpgradeData source appear in the Action popup” Did you find this to be the case?
Jason M
I believe I did. I would suggest asking Josh on codeplex.
jlembke
@jlembke, I will but in the meantime, were you able to work around it?
Jason M
Jason, I meant, I think I did get that action, but my memory is sketchy on that. Sorry to not be more help..
jlembke
+1  A: 

Here is what works in ASP.NET 4.0: http://www.olegsych.com/2010/07/understanding-aspnet-dynamic-data-filter-templates/

Oleg Sych

related questions