我正在尝试将日历Web部件添加到功能中的default.aspx页面。日历放在表单上,但我希望默认视图是摘要视图。我已经读过,如果您将ViewGuid
设置为string.Empty
,它会将视图设置为摘要视图,但这不起作用。
想法?
// Calendar
ListViewWebPart calendarWP = new ListViewWebPart();
SPList calendarList = site.Lists["Calendar"];
calendarWP.ListName = calendarList.ID.ToString("B").ToUpper();
calendarWP.ViewGuid = string.Empty;
oWPManager.AddWebPart(calendarWP, "Left", 3);
答案 0 :(得分:1)
经过一些挖掘和实验,我找到了解决这个谜团的方法。
SPList calendarList = site.Lists["Calendar"];
calendarWP.ListName = calendarList.ID.ToString("B").ToUpper();
calendarWP.ViewGuid = string.Empty;
oWPManager.AddWebPart(calendarWP, "Left", 3);
SPList calendarList = site.Lists["Calendar"];
calendarWP.ListName = calendarList.ID.ToString("B").ToUpper();
SPView summaryView = calendarList.Views[string.Empty];
calendarWP.ViewGuid = summaryView.ID.ToString("B").ToUpper();
oWPManager.AddWebPart(calendarWP, "Left", 3);
希望这有助于其他人