Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am adding a XsltListViewWebPart dynamically to an asp Panel. This code works except I cannot get the calendar view to display. Despite specifying the guid, a regular list view will appear (Even though the 'Calendar' view is selected on load). Any suggestions? ty

SPWeb oWebsite = SPContext.Current.Web;
SPList oList = oWebsite.Lists["Events"];
SPView view = oList.Views["Calendar"];    
XsltListViewWebPart lvwp = new XsltListViewWebPart();
lvwp.ListDisplayName = "Events";
lvwp.ViewFlags = SPViewFlags.Calendar;
lvwp.ViewId = Int32.Parse(view.BaseViewID);
lvwp.ViewGuid = view.ID.ToString("B");
pnlListVIew.Controls.Add(lvwp);
share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.