public void AddListToPage(SPFile homePage, SPList list)
 {
     XsltListViewWebPart wp = new XsltListViewWebPart();
     wp.ListName = list.ID.ToString("B").ToUpper();
     ModifyViewClass viewOperations = new ModifyViewClass();
     SPView defaultView = viewOperations.GetDefaultView(list);
     SPView copiedView = viewOperations.CopyView(defaultView, list);
     viewOperations.SetToolbarType(copiedView, "Standard");
     wp.ViewGuid = defaultView.ID.ToString("B").ToUpper();
     wp.Title = list.Title;
     InsertWebPartIntoWikiPage(homePage, wp, "{{1}}");
 }
        public XsltListViewWebPart AddListToPage(SPList list, string title, string zone, SPLimitedWebPartManager webPartManager, int index)
        {
            // validation
            list.RequireNotNull("list");
            title.RequireNotNullOrEmpty("title");
            zone.RequireNotNullOrEmpty("zone");
            webPartManager.RequireNotNull("webPartManager");
            index.Require(index >= 0, "index");

            XsltListViewWebPart wp = new XsltListViewWebPart();
            wp.ListName = list.ID.ToString("B").ToUpper();
            wp.Title = title;
            wp.ZoneID = zone;
            ModifyViewClass viewOperations = new ModifyViewClass();
            SPView defaultView = viewOperations.GetDefaultView(list);
            SPView modifiedView = viewOperations.CopyView(defaultView, list);
            viewOperations.SetToolbarType(modifiedView, "Standard");
            modifiedView.Update();
            wp.ViewGuid = modifiedView.ID.ToString("B").ToUpper();
            webPartManager.AddWebPart(wp, zone, index);
            list.Update();
            webPartManager.SaveChanges(wp);
            return wp;
        }