我正在使用 SPLimitedWebPartManager 访问内容查询 Web 部件的 Web 部件属性,以便以编程方式修改 CQWP 的“分组依据”属性......不幸的是,我不确定如何访问该特定属性,我似乎能够修改标题、描述等......但不能修改分组/排序属性......关于如何做到这一点的任何线索?
这是代码:
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);
}
谢谢!