以编程方式设置QueryStringFilterWebPart / ExcelWebRenderer连接

时间:2010-06-02 01:00:59

标签: sharepoint web-parts

代码

        public static void ChartPageConnector(SPWeb web, string pageURL, string providerWpId, string consumerWpId, string mappedName)
    {
        SPFile file = web.Files[pageURL];
        SPLimitedWebPartManager mgr = file.GetLimitedWebPartManager(PersonalizationScope.Shared);

        TransformableFilterValuesToFilterValuesTransformer transformer = new TransformableFilterValuesToFilterValuesTransformer();
        transformer.MappedConsumerParameterName = mappedName;

        //QueryStringFilterWebPart provider = (QueryStringFilterWebPart)mgr.WebParts[providerWpId];
        //ExcelWebRenderer consumer = (ExcelWebRenderer)mgr.WebParts[consumerWpId];
        JWP.WebPart provider = mgr.WebParts[providerWpId];
        JWP.WebPart consumer = mgr.WebParts[consumerWpId];


        ProviderConnectionPoint pcp = null;
        foreach (ProviderConnectionPoint ppoint in mgr.GetProviderConnectionPoints(provider))
        {
            if (ppoint.InterfaceType ==
            typeof(Microsoft.SharePoint.WebPartPages.ITransformableFilterValues))
            {
                pcp = ppoint;
                break;
            }
        }

        ConsumerConnectionPoint ccp = null;
        foreach (ConsumerConnectionPoint cpoint in mgr.GetConsumerConnectionPoints(consumer))
        {
            if (cpoint.InterfaceType == typeof(IFilterValues))
            {
                ccp = cpoint;
                break;
            }
        }

        //mgr.SPConnectWebParts(provider, pcp, consumer, ccp);
        mgr.SPConnectWebParts(provider, pcp, consumer, ccp, transformer);

        file.Update();
        web.Update();
    }

错误

“g_33d68e82_6478_4629_a079_5a7e02ac4695”上的连接点“IFilterValues”已禁用。

任何想法为什么

0 个答案:

没有答案