Posts

Showing posts with the label listview webpart

Add calendar summary view list view webpart

Hi, Sometimes client asked to add list view web part on the home page of the site. Its easy to add this view just by user interface with some little configuration changes. But using the feature you must know the trick to get the summary view of the calender list. Use following code just create a summary view of the list. var calendarlist = web.Lists.TryGetList("Calender"); var webpart = new ListViewWebPart { ListName = calendarlist.ID.ToString("B").ToUpper(), ViewGuid = calendarlist.Views[string.Empty].ID.ToString("B").ToUpper()// Use //String.Empty if you are using SP 2007. }; manager.AddWebPart(webpart, "Middle", 3); Few more things you can perform if you want to do some more modifications in the view 1) To get the BaseViewId '0' simple use the following code: var webpart = new ListViewWebPart { ListName = calendarlist.ID.ToString("B").ToUpper() }; var view = calendarlist.GetUncustomizedViewByBaseViewId(0); 2) To add a new fi...