0

考虑以下:

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

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

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

平台: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
4

1 回答 1

0

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

于 2012-08-06T08:18:26.067 回答