I have a couple of webparts on a page, XsltListViewWebPart and SPSlicerTextWebPart instances. I need to programmatically connect the filter (slicer) to the xslt webpart. When I do so, I need a transformer to transform the filtervalues to the correct format. I use the TransformableFilterValuesToParametersTransformer for this. The connect code is:

/// <summary>
/// Connects two webparts to each other
/// </summary>
/// <param name="consumerWebPart">The webpart which will consume the data</param>
/// <param name="consumerInterfaceType">The type of interface the consumer endpoint should have</param>
/// <param name="providerWebPart">The webpart which will provide the data</param>
/// <param name="providerInterfaceType">The type of interface the provider endpoint should have</param>
public void ConnectBusinessDataWebParts(
  System.Web.UI.WebControls.WebParts.WebPart consumerWebPart,
  string consumerConnectionPoint,
  System.Web.UI.WebControls.WebParts.WebPart providerWebPart,
  string providerConnectionPoint,
  WebPartTransformer transformer)
  // Get the connection point for the consumer.
  System.Web.UI.WebControls.WebParts.ConsumerConnectionPointCollection consumerConnections =

  ConsumerConnectionPoint consumerConnection = null;
  foreach (ConsumerConnectionPoint cpoint in consumerConnections)
    if (cpoint.ID == consumerConnectionPoint)
      consumerConnection = cpoint;

  // Get the connection point for the provider.
  System.Web.UI.WebControls.WebParts.ProviderConnectionPointCollection providerConnections =
  ProviderConnectionPoint providerConnection = null;
  foreach (ProviderConnectionPoint ppoint in providerConnections)
    if (ppoint.ID == providerConnectionPoint)
      providerConnection = ppoint;

  // when a transformer was used; create a new connection based on it; otherwise without one
  if (transformer != null)
    Microsoft.SharePoint.WebPartPages.SPWebPartConnection newConnection =
        providerWebPart, providerConnection,
        consumerWebPart, consumerConnection,

    Microsoft.SharePoint.WebPartPages.SPWebPartConnection newConnection =
          providerWebPart, providerConnection,
          consumerWebPart, consumerConnection);

This gives me the following exception: The transformer type "Microsoft.SharePoint.WebPartPages.TransformableFilterValuesToParametersTransformer" is not allowed to be used on this page.

Which is weird, because when I connect the webparts through the interface it all works fine and an instance of the same TransformableFilterValuesToParametersTransformer is added. I also checked all properties and stuff, everything matches with what the GUI creates when I couple things in there.

Update 1: I used reflector to check what's going on inside. The problem seems to lie with the !base.AvailableTransformers.Contains(type)) check. That returns false becase the AvailableTransformers collection doesn't contain the transformer I need. This collection is created upon instantiation, when my page is still empty. The available transformers are read from the webparts which aren't there yet. After that, the collection doesn't seem to be refreshed when new webparts are added.

Update 2: Crap, doesn't work. A simple solutions seems to be reinstantiation of the entire SPLimitedWebPartManager object, which will force the collection to reread the webpart transformers. I'm going to try that next.

Update 3: sadly, I still don't have it working properly


I've also had such issue. I created Command Line application and tried to go through pages and update connections, but it failed.

I found only one solution - create feature instead of command line application:

  1. I created site scope feature which removes old connections from WebParts and sets new connections in feature's FeatureActivated method. I've done similar actions as described in your question to connect WebParts.
  2. Deployed, then activated in particular site collection and then removed from SharePoint.
  • So the same code worked in a feature but not in a commandline app? Could have something to do with SharePoint context, I'm running this code from a custom WCF service (in context though). – Jasper May 12 '11 at 6:42
  • Sorry to mark this unanswered, but I deployed the code I was using to the production farm where it breaks again. I think it has something todo with security / credentials instead of the transformer type not being allowed. – Jasper May 30 '11 at 10:40

We had the same issues as you have, i must admit it is really awkward the behaviour you face. One of the transformer you are injecting in your method is a not allowed type on webpart pages.

Our issue was that we used the following transformer type:


, this one is not supported and should be changed with the following:


Check the namespace differences and you will be amazed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.