删除时,根网站中提供的XlstViewWebPart列表不存在



考虑以下内容:

我有一个管理子网站,它有所有列表和文档库,我使用XlstViewWebPart以编程方式在根网站中提供大多数文档库,当我尝试选择一个项目并使用功能区上的删除按钮删除它时,我得到:

服务器遇到以下错误:列表不存在。您选择的页面包含一个不存在的列表。它可能已被其他用户删除

但是,如果从项目弹出菜单中删除项目,它工作正常并被删除!!!!

平台:SharePoint Server 2010 SP1,VS 2010,CU 2012年6月

提前感谢

========================================

更新(我的代码用于提供web部件)

            Dim _web As SPWeb = SPContext.Current.Site.RootWeb
        Try
            'Get refrence to publishing web
            Dim _pubWeb As PublishingWeb = PublishingWeb.GetPublishingWeb(_web)
            Dim WPM As Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager
            If _pubWeb IsNot Nothing Then
                'Loop each publishing page in the web
                'Check out the file
                'If the current page have CustomWebPart (It is an Custom System Page), Then
                'If XsltListViewWebPart is not provisiond (double check in case of click the button more than one time), then
                'Create an XsltListViewWebPart
                'Assign properties of the new XsltListViewWebPart with Document Lib. Name and Admin web
                'Add the new XsltListViewWebPart to the current page in the loop
                For Each curPage As PublishingPage In _pubWeb.GetPublishingPages()
                    If curPage.ListItem.File.RequiresCheckout AndAlso curPage.ListItem.File.CheckOutType = SPFile.SPCheckOutType.None Then curPage.CheckOut()
                    WPM = curPage.ListItem.File.GetLimitedWebPartManager(System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared)
                    Dim CustomWebPart As CustomWebPart = WPM.WebParts.OfType(Of CustomWebPart)().FirstOrDefault()
                    If CustomWebPart IsNot Nothing Then
                        If CustomWebPart.DocLibName.ToLower = Constants.List.MeetingSchedular.ListName.ToLower Then Continue For
                        Dim web As SPWeb = _web.Site.RootWeb.Webs(Constants.WebNames.AdminWeb) 'Get Admin Web
                        Dim LVWP As WebPartPages.XsltListViewWebPart = WPM.WebParts.OfType(Of WebPartPages.XsltListViewWebPart)().FirstOrDefault()
                        If LVWP Is Nothing Then
                            LVWP = New WebPartPages.XsltListViewWebPart
                            Dim lst As SPList = web.Lists(CustomWebPart.DocLibName)
                            With LVWP
                                .WebId = web.ID
                                .ViewGuid = lst.DefaultView.ID.ToString("B").ToUpper()
                                .ListName = lst.ID.ToString("B").ToUpper()
                                .ListId = lst.ID
                                .ListUrl = "/Admin/" + CustomWebPart.DocLibName
                                .TitleUrl = "/Admin/" + CustomWebPart.DocLibName
                                .ChromeType = System.Web.UI.WebControls.WebParts.PartChromeType.None
                                .AllowClose = False
                                .AllowEdit = True
                                .AllowMinimize = True
                                .AllowConnect = True
                            End With
                            _web.AllowUnsafeUpdates = True
                            WPM.AddWebPart(LVWP, "MainZone", 0)
                            curPage.Update()
                            _web.AllowUnsafeUpdates = False
                        End If
                        curPage.CheckIn("By cmdProvisionWebParts_Click")
                        curPage.ListItem.File.Publish("By cmdProvisionWebParts_Click")
                    End If
                Next
            End If
            RegisterNotification("Provision Web Parts Completed successfully")
        Catch ex As Exception
            SiteHelper.WriteErrors("Custom_Settings.ProvisioningRootWebParts", ex)
            RegisterNotification("Error: " + ex.Message)
        End Try

可能,发生错误是因为您的列表属于另一个网站(或子网站),而SP告诉您,它没有列表。请尝试在您的网站中创建列表,然后再次删除。如果它不起作用,请向我们展示您的XlstViewWebPart代码。

最新更新