BDC Web 部件连接接口错误
我想从(提供商)businessdata 过滤器 Web 部件向 BDC 列表 Web 部件提供“查询值”。 当我尝试连接时出现错误。 “提供者连接点 (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);
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看起来您正在比较两种不同的连接接口。 您的提供者连接实现 ITransformableFilterValues,您的使用者连接实现 IWebPartParameters。
我对您在这里编写的代码了解不多,因为我很少在代码中编写 Web 部件之间的连接。 但连接的重点是消费者和提供者必须提供并期望相同的接口。
您是否尝试过在浏览器界面中将这两个 Web 部件连接在一起?
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?
我对此问题的直接经验是将查询字符串筛选器 Web 部件作为提供者,将报表查看器 Web 部件作为使用者,但问题是相同的。
ITransformableFilterValues 接口不可由 IWebPartParameters 接口使用。 但连接点集合中的每个项目都实现不同的接口类型。
在调试器中,检查 ConsumerConnectionPointCollection 和 ProviderConnectionPointConnection 实现的其他接口类型。 如果两个集合都具有实现相同接口类型的连接,请在检查接口类型的 foreach 中使用该接口类型。
如果没有直接匹配,您应该尝试找到正确的组合。
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.
您需要使用正确的转换器和以转换作为参数的覆盖方法,以便两个接口可以连接/转换。 来自 TransformableFilterValuesToParametersTransformer 的 msdn 文档:“允许实现 Microsoft.SharePoint.WebPartPages.ITransformableFilterValues 的标准筛选器连接到可以使用 IWebPartParameters 的任何 Web 部件”
webPartManager.SPConnectWebParts(
提供者WebPart、提供者连接、消费者WebPart、消费者连接、变压器);
You need to use the correct transformer and the override method with the transformation as a parameter so the two interfaces can connect/transform. From the msdn documentation on the TransformableFilterValuesToParametersTransformer: "Allows standard filters, which implement Microsoft.SharePoint.WebPartPages.ITransformableFilterValues, to connect to any Web Part that can consume IWebPartParameters"
webPartManager.SPConnectWebParts(
providerWebPart, providerConnection, consumerWebPart, consumerConnection,transformer);