2009-06-15 51 views
2

我想向(Provider)businessdata filter webpart的BDC List WebPart提供“查询值”。我尝试连接时遇到错误。 “提供程序连接点(BusinessDataFilterWebPart)和使用者连接点”BusinessDataListWebPart“不使用相同的连接接口。”BDC Web部件连接接口错误

以下是我的代码片段。

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

回答

0

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

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

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

0

我对此问题的直接体验是查询字符串筛选器Web部件作为提供者,报告查看器Web部件作为使用者,但问题相同。

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

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

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

0

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

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

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