【问题标题】:Delete multiple sharepoint list items programmatically according to some column value根据某些列值以编程方式删除多个共享点列表项
【发布时间】:2019-09-04 23:47:40
【问题描述】:
  • 我想通过代码删除文档库项。
  • 假设 Doc 库有一列 FolderId。
  • 我想删除 FolderId 为 33 的所有项目。

我正在尝试通过代码将其删除,但仅删除了 FolderId 33 的第一次出现。

当我尝试删除第二个匹配项时,出现以下异常:

“Microsoft.SharePoint.SPException:项目不存在。它可能已被其他用户删除。在 Microsoft.SharePoint.SPListItem.EnsureItemIsValid() 在 Microsoft.SharePoint.SPListItem.PrepareItemForUpdate(Guid newGuidOnAdd, SPWeb web, Boolean bMigration, Boolean& bAdd, Boolean& bPublish, Object& objAttachmentNames, Object& objAttachmentContents, Int32& parentFolderId) at Microsoft.SharePoint.SPListItem.UpdateInternal(Boolean bSystem, Boolean bPreserveItemVersion, Guid newGuidOnAdd, 布尔 bMigration, Boolean bPublish, Boolean bNoVersion, Boolean bCheckOut, Boolean bCheckin ASP._0443e3f9_0806_46ea_98ce_21e2d9f6c224_1904097461.btnDelete_Click(Object sender, EventArgs e) 处 Microsoft.SharePoint.SPListItem.Update() 处的布尔型 suppressAfterEvents)" 请帮助我如何根据folderId从文档库中删除所有项目

【问题讨论】:

    标签: sharepoint-2007


    【解决方案1】:

    尝试向后浏览集合:

    for (int i = items.Count - 1; i >= 0; i--)
    {
        SPListItem item = items[i];
        item.Delete();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-18
      • 1970-01-01
      • 2022-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多