views:

354

answers:

2

I want to provide "Query Value" to the BDC List WebPart from (Provider) businessdata filter webpart. I get fllowing error when i try to connect. "The provider connection point (BusinessDataFilterWebPart) and the consumer connection point "BusinessDataListWebPart" do not use the same connection interface."

Following is my code snippet.

System.Web.UI.WebControls.WebParts.WebPart providerWebPart =
                webPartManager.WebParts[filterWebPart.ID];
            ProviderConnectionPointCollection providerConnections =
                webPartManager.GetProviderConnectionPoints(providerWebPart);
            ProviderConnectionPoint providerConnection = null;
            foreach (ProviderConnectionPoint ppoint in providerConnections)
            {
                if (ppoint.InterfaceType == typeof(ITransformableFilterValues))
                    providerConnection = ppoint;

            }
            System.Web.UI.WebControls.WebParts.WebPart consumerWebPart =
                webPartManager.WebParts[consumer.ID];
            ConsumerConnectionPointCollection consumerConnections =
                webPartManager.GetConsumerConnectionPoints(consumerWebPart);
            ConsumerConnectionPoint consumerConnection = null;

            foreach (ConsumerConnectionPoint cpoint in consumerConnections)
            {
               if (cpoint.InterfaceType == typeof(IWebPartParameters))
                   consumerConnection = cpoint;
            }

 SPWebPartConnection newConnection = webPartManager.SPConnectWebParts(
                providerWebPart, providerConnection, consumerWebPart, consumerConnection);
A: 

It looks like you are comparing two different connection interfaces. Your provider connection implements ITransformableFilterValues and your consumer connection implements IWebPartParameters.

I don't know much about the code you have written here as I rarely write connections between web parts in code. But the whole point about connections is the consumer and provider have to provide and expect the same interface.

Have you tried connecting these two web parts together in the browser interface?

Charlie
A: 

My direct experience with this problem is with the query string filter web part as the provider and the report viewer web part as the consumer, but the issue was the same.

The ITransformableFilterValues interface is not consumable by the IWebPartParameters interface. But each item in the connection points collection implements a different interface type.

In your debugger, check the other interface types implemented by both the ConsumerConnectionPointCollection and ProviderConnectionPointConnection. If both collections have connections that implement the same interface type, use that interface type in the foreaches where you are checking the interface type.

If there is no direct match, you should experiment to find the right combination.

Adam Roderick