场景1:添加List View Webpart

 //Add webpart in view by location
                    SPList oList = web.Lists[Constant._CUSTOMER_CONTRACT_LIST_TITLE];
                    ListViewWebPart oListViewWebPart = new ListViewWebPart();
                    oListViewWebPart.ZoneID = "Left";
                    oListViewWebPart.ListName = oList.ID.ToString("B").ToUpper();
                    oListViewWebPart.ViewGuid = oList.Views[0].ID.ToString("B").ToUpper();
                    SPWebPartCollection collWebParts = web.GetWebPartCollection("default.aspx", Storage.Shared);
                    System.Guid guid = collWebParts.Add(oListViewWebPart);

  

场景2:添加自定义WebPart

//Add webpart in view by location
                        string url = web.Url + "/Lists/SafetyLab/ByLocation.aspx";
                        SPFile file = web.GetFile(url);
                        SPLimitedWebPartManager webPartManager =
                        file.GetLimitedWebPartManager(PersonalizationScope.Shared);
                        Microsoft.SharePoint.WebPartPages.WebPart wpReport = new ALU.C0370A.VPPI.ReportWebPart();
                        webPartManager.AddWebPart(wpReport, "Main", 0);

  

相关文章:

  • 2021-05-27
  • 2021-10-17
  • 2021-07-20
  • 2022-12-23
  • 2021-08-15
  • 2022-12-23
  • 2021-12-11
  • 2021-10-15
猜你喜欢
  • 2021-05-17
  • 2022-02-06
  • 2021-08-30
  • 2021-10-08
  • 2021-07-11
  • 2021-09-04
  • 2022-01-04
相关资源
相似解决方案