首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何通过代码访问SharePoint 2010中内容查询Web部件的分组属性?

如何通过代码访问SharePoint 2010中内容查询Web部件的分组属性?
EN

Stack Overflow用户
提问于 2012-06-01 18:18:20
回答 1查看 586关注 0票数 0

我正在使用SPLimitedWebPartManager访问内容查询Web部件的Web部件属性,以便以编程方式修改CQWP的"Grouped“属性...不幸的是,我不确定如何访问这个特定的属性,我似乎能够修改标题,描述等…而不是分组/排序属性...有关于如何做到这一点的线索吗?

代码如下:

代码语言:javascript
运行
复制
SPFile ofile = page.File;

SPLimitedWebPartManager wpColl = ofile.GetLimitedWebPartManager(System.Web.UI.WebControls.WebParts.PersonalizationScope.User);
int cont = wpColl.WebParts.Count;

Console.WriteLine("    - " + page.Name);

for (int i = 0; i < cont; i++)
{
    System.Web.UI.WebControls.WebParts.WebPart wp1 = wpColl.WebParts[i];

    Console.WriteLine("        Personal: " + wp1.ToString());
    Console.WriteLine("        - Title: " + wp1.Title);
    Console.WriteLine("        - ID: " + wp1.ID);

    if (wp1.Title.Equals("CQWP Title"))
    {
        wp1.Title = "WebPart_CQWP";
        Console.WriteLine("        - New Title " + wp1.Title);

        // ----- here I would like to add the same thing to update the Group By property (or any other property which would be useful in order to configure the CQWP (list, type of document we are filtering, etc...) ---- how can I do that?
    }

    ofile.Update();
    wpColl.SaveChanges(wp1);
}

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2012-06-01 19:19:09

好了,我知道怎么做了。我需要将这个the部件转换为CQWP,以便能够访问它的确切设置。在代码中添加了以下内容:

代码语言:javascript
运行
复制
Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart cqwp = (Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart)wp1;

                                    Console.WriteLine("................." + cqwp.GroupBy);

现在,我可以访问not部件的GroupBy属性,否则该属性不可用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10848461

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档