2

我想从(提供者)businessdata filter webpart 向 BDC List WebPart 提供“查询值”。当我尝试连接时出现错误。“提供者连接点(BusinessDataFilterWebPart)和消费者连接点“BusinessDataListWebPart”不使用相同的连接接口。”

以下是我的代码片段。

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);
4

3 回答 3

0

看起来您正在比较两个不同的连接接口。您的提供者连接实现 ITransformableFilterValues,而消费者连接实现 IWebPartParameters。

我对您在这里编写的代码了解不多,因为我很少在代码中编写 Web 部件之间的连接。但是关于连接的重点是消费者和提供者必须提供并期望相同的接口。

您是否尝试在浏览器界面中将这两个 Web 部件连接在一起?

于 2009-06-16T12:46:53.077 回答
0

我对这个问题的直接体验是将查询字符串过滤器 Web 部件作为提供者,将报表查看器 Web 部件作为消费者,但问题是相同的。

ITransformableFilterValues 接口不能由 IWebPartParameters 接口使用。但是连接点集合中的每个项目都实现了不同的接口类型。

在您的调试器中,检查 ConsumerConnectionPointCollection 和 ProviderConnectionPointConnection 实现的其他接口类型。如果两个集合都有实现相同接口类型的连接,请在检查接口类型的 foreaches 中使用该接口类型。

如果没有直接匹配,您应该尝试找到正确的组合。

于 2010-02-12T16:05:19.227 回答
0

您需要使用正确的转换器和将转换作为参数的覆盖方法,以便两个接口可以连接/转换。从有关 TransformableFilterValuesToParametersTransformer 的 msdn 文档中:“允许实现 Microsoft.SharePoint.WebPartPages.ITransformableFilterValues 的标准过滤器连接到可以使用 IWebPartParameters 的任何 Web 部件”

var transformer = new TransformableFilterValuesToParametersTransformer();
               transformer.ProviderFieldNames = new string[] { "DocumentIdForCurrentPage" };
               transformer.ConsumerFieldNames = new string[] { "DocumentId" };

webPartManager.SPConnectWebParts(providerWebPart,providerConnection,consumerWebPart,consumerConnection,变压器);

于 2012-05-09T20:13:34.313 回答