0
我正在使用SPLimitedWebPartManager訪問內容查詢Web部件的Web部件屬性,以編程方式修改CQWP的「Grouped by」屬性...不幸的是,我不確定如何訪問該特定屬性,而我似乎可以修改標題,說明等...但不能分組/排序屬性...任何線索如何做到這一點?如何通過代碼訪問SharePoint 2010中的內容查詢Web部件的分組屬性?
下面是代碼:
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);
}
謝謝!