Lists.UpdateListItems 方法 (websvcLists)

Windows SharePoint Services 3
 
Adds, deletes, or updates the specified items in a list on the current site.

命名空间: websvcLists
程序集: STSSOAP (在
stssoap.dll 中)

[SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/UpdateListItems", RequestNamespace="http://schemas.microsoft.com/sharepoint/soap/", ResponseNamespace="http://schemas.microsoft.com/sharepoint/soap/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)]
public XmlNode UpdateListItems (
string listName,
XmlNode updates
)

参数

listName

A string that contains the name of the list. It is recommended that you use the list GUID surrounded by curly braces (i.e., "{GUID}"), but you can also use the list display name.

updates

A Batch element that contains one or more methods for adding, modifying, or deleting items and that can be assigned to a System.Xml.XmlNode object.

The following example shows how to modify column values for two specified items.

<Batch OnError="Continue" ListVersion="1"
ViewName="270C0508-A54F-4387-8AD0-49686D685EB2">
<Method ID="1" Cmd="Update">
<Field Name="ID">4<Field>
<Field Name="Field_Name">Value</Field>
</Method>
<Method ID="2" Cmd="Update">
<Field Name="ID" >6</Field>
<Field Name="Field_Name">Value</Field>
</Method>
</Batch>

An empty ViewName attribute in the Batch element causes the default view to be used. The ID attribute in each Method element uniquely identifies the specific update so that errors and return values can be properly identified. Each method that is posted contains Field elements that specify the ID of the item and the new field value for the item. The field ID does not correspond to the index of the item in the collection of items for the list.

The following example shows the format for adding a new item that contains both a Date value and a DateTime value.

<Batch OnError="Continue" ListVersion="1"
ViewName="270C0508-A54F-4387-8AD0-49686D685EB2">
<Method ID="1" Cmd="New">
<Field Name='ID'>New</Field>
<Field Name="Title">Value</Field>
<Field Name="Date_Column">2007-3-25</Field>
<Field Name="Date_Time_Column">
2006-1-11T09:15:30Z</Field>
</Method>
</Batch>

The following example shows how to delete two items.

<Batch OnError="Continue" ListVersion="1"
ViewName="270C0508-A54F-4387-8AD0-49686D685EB2">
<Method ID="1" Cmd="Delete">
<Field Name='ID'>2</Field>
</Method>
<Method ID="2" Cmd="Delete">
<Field Name='ID'>8</Field>
</Method>
</Batch>
注意:

IDs for deleted items are maintained after delete operations. Consequently, the example deletes the second and eighth items in the list, but 2 and 8 are not reassigned as the IDs of other items.

For descriptions of the various formats used for field types that can be passed in this parameter see SPListItem.

The following examples show the methods that can be posted for operations related to document libraries:

  • Create a folder

    <Batch OnError="Continue" PreCalc="TRUE"
    ListVersion="0"
    ViewName="{EF2F5A21-0FD0-4654-84ED-112B4F5A48F8}">
    <Method ID="1" Cmd="New">
    <Field Name="ID">New</Field>
    <Field Name="FSObjType">1</Field>
    <Field Name="BaseName">Name</Field>
    </Method>
    </Batch>
  • Update a folder

    <Batch OnError="Continue" PreCalc="TRUE"
    ListVersion="0"
    ViewName="{EF2F5A21-0FD0-4654-84ED-112B4F5A48F8}">
    <Method ID="1" Cmd="Update">
    <Field Name="ID">3</Field>
    <Field Name="owshiddenversion">1</Field>
    <Field Name="FileRef">
    http://Server/[sites/][Site/]Shared
    Documents/Folder</Field>
    <Field Name="FSObjType">1</Field>
    <Field Name="BaseName">Name</Field>
    </Method>
    </Batch>
  • Delete a folder

    <Batch OnError="Continue" PreCalc="TRUE"
    ListVersion="0"
    ViewName="{EF2F5A21-0FD0-4654-84ED-112B4F5A48F8}">
    <Method ID="1" Cmd="Delete">
    <Field Name="ID">4</Field>
    <Field Name="FileRef">
    http://Server/[sites/][Site/]Shared
    Documents/Folder</Field>
    </Method>
    </Batch>
  • Update documents

    <Batch OnError="Continue" PreCalc="TRUE"
    ListVersion="0"
    ViewName="{EF2F5A21-0FD0-4654-84ED-112B4F5A48F8}">
    <Method ID="1" Cmd="Update">
    <Field Name="ID">2</Field>
    <Field Name="owshiddenversion">1</Field>
    <Field Name="FileRef">
    http://Server/[sites/][Site/]Shared
    Documents/File</Field>
    <Field Name="BaseName">Name</Field>
    </Method>
    </Batch>
  • Delete documents

    <Batch OnError="Continue" PreCalc="TRUE"
    ListVersion="0"
    ViewName="{EF2F5A21-0FD0-4654-84ED-112B4F5A48F8}">
    <Method ID="1" Cmd="Delete">
    <Field Name="ID">3</Field>
    <Field Name="FileRef">
    http://Server/[sites/][Site/]Shared
    Documents/File</Field>
    </Method>
    </Batch>

返回值

An XMLDATA fragment in the following form that shows the status of each method block posted through the updates parameter and that can be assigned to a System.Xml.XmlNode object. For items successfully updated, a row fragment is returned with the updated row values.

<Results xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<Result ID="1,Update">
<ErrorCode>0x00000000</ErrorCode>
<z:row ows_ID="4" ows_Title="Title"
ows_Modified="2003-06-19 20:31:21"
ows_Created="2003-06-18 10:15:58"
ows_Author="3;#User1_Display_Name"
ows_Editor="7;#User2_Display_Name" ows_owshiddenversion="3"
ows_Attachments="-1"
ows__ModerationStatus="0" ows_LinkTitleNoMenu="Title"
ows_LinkTitle="Title"
ows_SelectTitle="4" ows_Order="400.000000000000"
ows_GUID="{4962F024-BBA5-4A0B-9EC1-641B731ABFED}"
ows_DateColumn="2003-09-04 00:00:00"
ows_NumberColumn="791.00000000000000"
xmlns:z="#RowsetSchema" />
</Result>
<Result ID="2,Update">
<ErrorCode>0x00000000</ErrorCode>
<z:row ows_ID="6" ows_Title="Title"
ows_Modified="2003-06-19 20:31:22"
ows_Created="2003-06-18 19:07:14"
ows_Author="2;#User1_Display_Name"
ows_Editor="6;#User2_Display_Name" ows_owshiddenversion="4"
ows_Attachments="0" ows__ModerationStatus="0"
ows_LinkTitleNoMenu="Title"
ows_LinkTitle="Title" ows_SelectTitle="6"
ows_Order="600.000000000000"
ows_GUID="{2E8D2505-98FD-4E3E-BFDA-0C3DEBE483F7}"
ows_DateColumn="2003-06-23 00:00:00"
ows_NumberColumn="9001.00000000000000"
xmlns:z="#RowsetSchema" />
</Result>
...
</Results>

In this example, the ows_Author and ows_Editor attributes pertain to lookup fields to another list in the database, representing the integer IDs of items in the UserInfo table and the actual values contained by these items within the table.

The following code example modifies the values of two different field values within two items in a list on the current site. The example uses an XmlDocument object to create XmlNode objects for parameters.

This example requires that a using (Visual C#) or Imports (Visual Basic) directive be included for the System.Xml namespace.

Web_Reference_Folder.Lists listService = new Web_Reference_Folder.Lists();
listService.Credentials= System.Net.CredentialCache.DefaultCredentials; string strBatch = "<Method ID='1' Cmd='Update'>" +
"<Field Name='ID'>4</Field>" +
"<Field Name='Field_Number'>999</Field></Method>" +
"<Method ID='2' Cmd='Update'><Field Name='ID' >6</Field>" +
"<Field Name='Field_DateTime'>
2003-11-11T09:15:30Z</Field></Method>"; XmlDocument xmlDoc = new System.Xml.XmlDocument(); System.Xml.XmlElement elBatch = xmlDoc.CreateElement("Batch"); elBatch.SetAttribute("OnError","Continue");
elBatch.SetAttribute("ListVersion","1");
elBatch.SetAttribute("ViewName",
"0d7fcacd-1d7c-45bc-bcfc-6d7f7d2eeb40"); elBatch.InnerXml = strBatch; XmlNode ndReturn = listService.UpdateListItems("List_Name", elBatch); MessageBox.Show(ndReturn.OuterXml);

&amp;amp;lt;div&amp;amp;gt;&amp;amp;lt;img alt="DCSIMG" id="Img1" width="1" height="1" src="http://m.webtrends.com/dcsmgru7m99k7mqmgrhudo0k8_8c6m/njs.gif?dcsuri=/nojavascript&amp;amp;amp;amp;WT.js=No" /&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;&amp;amp;lt;a href="http://www.omniture.com" title="Web Analytics"&amp;amp;gt; &amp;amp;lt;img src="//msstonojsmsdn.112.2o7.net/b/ss/msstonojsmsdn/1/H.20.2--NS/0" height="1" width="1" border="0" alt="" /&amp;amp;gt; &amp;amp;lt;/a&amp;amp;gt;

Sharepoint CAML 增删改查 List的更多相关文章

  1. Dapper逆天入门~强类型,动态类型,多映射,多返回值,增删改查+存储过程+事物案例演示

    Dapper的牛逼就不扯蛋了,答应群友做个入门Demo的,现有园友需要,那么公开分享一下: 完整Demo:http://pan.baidu.com/s/1i3TcEzj 注 意 事 项:http:// ...

  2. ASP.NET从零开始学习EF的增删改查

           ASP.NET从零开始学习EF的增删改查           最近辞职了,但是离真正的离职还有一段时间,趁着这段空档期,总想着写些东西,想来想去,也不是很明确到底想写个啥,但是闲着也是够 ...

  3. 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(9)-MVC与EasyUI结合增删改查

    系列目录 文章于2016-12-17日重写 在第八讲中,我们已经做到了怎么样分页.这一讲主要讲增删改查.第六讲的代码已经给出,里面包含了增删改,大家可以下载下来看下. 这讲主要是,制作漂亮的工具栏,虽 ...

  4. 通过Java代码实现对数据库的数据进行操作:增删改查

    在写代码之前,依然是引用mysql数据库的jar包文件:右键项目-构建路径-设置构建路径-库-添加外部JAR 在数据库中我们已经建立好一个表xs :分别有xuehao  xingming    xue ...

  5. Hibernate全套增删改查+分页

    1.创建一个web工程 2.导入jar包 3.创建Student表 4.创建实体类 package com.entity; public class Student { private Integer ...

  6. 使用 Json.Net 对Json文本进行 增删改查

    JSON 已经成为当前主流交互格式, 如何在C#中使用 Json.Net 对Json文本进行 增删改查呢?见如下代码 #region Create (从零创建) public static strin ...

  7. yii2 增删改查

    自己总结的yii2 advanced 版本的简单的增删改查,希望对大家有所帮助 1.gii生成的actionCreate()方法中 获取插入语句的id $id = $model->attribu ...

  8. Batis-iBatis基本操作(增删改查)

    Batis-iBatis基本操作(增删改查) 时间 2014-04-10 17:55:20  CSDN博客 原文  http://blog.csdn.net/mazhaojuan/article/de ...

  9. JS组件系列——又一款MVVM组件:Vue(一:30分钟搞定前端增删改查)

    前言:关于Vue框架,好几个月之前就听说过,了解一项新技术之后,总是处于观望状态,一直在犹豫要不要系统学习下.正好最近有点空,就去官网了解了下,看上去还不错的一个组件,就抽空研究了下.最近园子里vue ...

随机推荐

  1. Java文件操作与输入输出流

    文件操作 package ch15; import java.io.*; /** * Created by Jiqing on 2016/12/28. */ public class FileTest ...

  2. bridge

    1 意图:将抽象部分与实现部分分离,使得它们都可以独立地变化 2 别名:Handle/Body 3 动机:客户在创建窗口时应该不涉及到具体实现部分.仅仅是窗口的实现部分依赖于应用运行的平台. 客户代码 ...

  3. SPSS数据分析—非参数检验

    统计学的假设检验可以分为参数检验和非参数检验,参数检验都是根据一些假设条件推算而来,当这些假设条件无法满足的时候,参数检验的效能会大打折扣,甚至出现错误的结果,而非参数检验通常是没有假设条件的,因此应 ...

  4. Svn与Git的一些区别(转载)

    把第一条理解到位思想到位了做起来才会有的放矢,其他几条都是用的时候才能体会到 1) 最核心的区别Git是分布式的,而Svn不是分布的.能理解这点,上手会很容易,声明一点Git并不是目前唯一的分布式版本 ...

  5. 并发编程 02—— ConcurrentHashMap

    Java并发编程实践 目录 并发编程 01—— ThreadLocal 并发编程 02—— ConcurrentHashMap 并发编程 03—— 阻塞队列和生产者-消费者模式 并发编程 04—— 闭 ...

  6. 求助,JS 方法调用的问题,写了返回值,确调用时返回Undefined(新人第一次写)

    文本框txtUserName 的Onbulr 绑定方法 txtUserNameOnblur  这可以正常执行 而下面的btnRegister 的click 事件则无法正常调用    txtUserNa ...

  7. 69道Spring面试题和答案

    1. 什么是spring? Spring 是个java企业级应用的开源开发框架.Spring主要用来开发Java应用,但是有些扩展是针对构建J2EE平台的web应用.Spring 框架目标是简化Jav ...

  8. [最近公共祖先] POJ 1330 Nearest Common Ancestors

    Nearest Common Ancestors Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 27316   Accept ...

  9. css盒子模型层级3D图

    作为前端开发工程师,大家都应该知道盒子模型.下面用一张图来表达3D盒子模型的层级关系 大家可以看到background-color 在background-image的下一层.这个希望对大家有帮助

  10. Linux驱动之内存映射

    本文参考了http://www.cnblogs.com/geneil/archive/2011/12/08/2281222.html.本文作为学习总结,将主要过程简要描述. 很多驱动实现某些功能都要通 ...