Allow Connections for Filter property

Oct 19, 2007 at 4:13 PM
I'd like to filter by a url parameter. Would this require a mod to the code or is this doable via a custom query string?
Oct 22, 2007 at 12:11 AM
custom code only. Maybe in the next version I (or some volunteer) will add it
Oct 25, 2007 at 3:45 PM
We did this, and its pretty simple:

public class QueryStringContentQueryWebPart : ContentByQueryWebPart

protected override void OnDataBinding(EventArgs e)
if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString"MyParam"))
FilterValue1 = HttpContext.Current.Request.QueryString"MyParam";


You can choose to override both FilterValue1 to 3, FilterOperator1 to 3 and FilterType1 to 3
To make the above nicer, put the MyParam value in another EditorPart/ToolPart

Anders Rask
Nov 5, 2007 at 10:28 AM
Edited Nov 5, 2007 at 10:28 AM
Sorry for the maybe stupid question, but how do I apply this code? (basic steps, just point me in the right direction)

I need to display docs from different doclibs and filter them by URL parameter. New doclibs in the hierarchy must be automatically included in the query (so I can't use the standard DataView Webpart because there, I have to add each source manually).

So, of course I would also be glad to have this setting added to the next version - would be a great plus for the ECQWP ;-)
Nov 6, 2007 at 12:01 PM

you need to create a new web part in Visual Studio where you inherit from ContentByQueryWebPart (just like ECQWP does, so check the source for details) and override for example FilterValue1.

If the parameter you need to filter on is a custom column, you could also override FilterName1 (or 2 or 3) to use that custom field (i do this too in my web part since custom filters apparently are not supported OOTB)

Nov 6, 2007 at 1:37 PM
Oh yes, that helps. Thank you very much, I'll try that ASAP

(but anyway it would be good to include in the ECQWP as well)

Enhanced-DVWP would be a cool new project :-)
DataView is cool, supports parameter filtering, but doesn't support "relative source" like CQWP
CQWP supports "relative sources" but not parameter filtering. Best would actually be a DataView with relative source like CQWP (e.g. all doclibs under /departmentSales) because DVWP has so many other cool features. Time for E-DVWP!