首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何更新列表项?

问如何更新列表项?
EN

Stack Overflow用户
提问于 2014-01-29 23:10:29
回答 1查看 959关注 0票数 0

我一直试图使用c#以编程方式更新sharepoint网站上的列表项。我成功地完成了WebServerReference。然而,我不明白下列项目是什么:

ListId, viewId , FieldName ID等

在我从这里获取的下面一段代码中,我应该将这些ListId, viewId , FieldName ID值替换为我的值。我不知道从哪里可以得到这些价值。我一直在仔细检查sharepoint网站,但在任何地方都找不到这些值。

代码语言:javascript
复制
/*Get Name attribute values (GUIDs) for list and view. */
System.Xml.XmlNode ndListView = listService.GetListAndView("MyList", "");
string strListID = ndListView.ChildNodes[0].Attributes["Name"].Value;
string strViewID = ndListView.ChildNodes[1].Attributes["Name"].Value;

/*Create an XmlDocument object and construct a Batch element and its
attributes. Note that an empty ViewName parameter causes the method to use the default view. */
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
System.Xml.XmlElement batchElement = doc.CreateElement("Batch");
batchElement.SetAttribute("OnError", "Continue");
batchElement.SetAttribute("ListVersion", "1");
batchElement.SetAttribute("ViewName", strViewID);

/*Specify methods for the batch post using CAML. To update or delete, 
specify the ID of the item, and to update or add, specify 
the value to place in the specified column.*/
batchElement.InnerXml = "<Method ID='1' Cmd='Update'>" +
   "<Field Name='ID'>6</Field>" +
   "<Field Name='Title'>Modified sixth item</Field></Method>" +
   "<Method ID='2' Cmd='Update'><Field Name='ID'>7</Field>" +
   "<Field Name='Title'>Modified seventh item</Field></Method>" +
   "<Method ID='3' Cmd='Delete'><Field Name='ID'>5</Field>" +
   "</Method><Method ID='4' Cmd='New'>" +
   "<Field Name='Title'>Added item</Field></Method>";
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-01-30 01:53:20

尝试浏览列表设置页以从URL获取列表ID,从URL获取视图ID的修改视图页,以及列表设置页,然后单击字段从URL获取字段名。或者您可以尝试类似Codeplex上的SharePoint管理器来轻松找到这些信息。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21444680

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档