开发者

Programmatically Set a QueryStringFilterWebPart / ExcelWebRenderer Connection

Code:

        public static void ChartPageConnector(SPWeb web, string pageURL, string providerWpId, string consumerWpId, string mappedName)
    {
        SPFile file = web.Files[pageURL];
        SPLimitedWebPartManager mgr = file.GetLimitedWebPartManager(Persona开发者_StackOverflowlizationScope.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();
    }

Error:

The connection point "IFilterValues" on "g_33d68e82_6478_4629_a079_5a7e02ac4695" is disabled.

Any Ideas Why?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜