开发者

Add data to sharepoint form programmatically on client

I have a need to edit a Sharepoint form programmatically to update a te开发者_如何学编程xt box on a form. The url of this form is https://sharepointserver/NameOfList/DispForm.aspx?ID=141. Using the sharepoint web services how can I add data to a field called "Description" on the form?


First - add a web service to your visual studio project to interact with SharePoint from windows/console app: Accessing SharePoint Web-Services with Visual Studio 2008

Then call WssLists.UpdateListItems

string strBatch = "<Method ID='1' Cmd='Update'>" + 
    "<Field Name='ID'>141</Field>" +
    "<Field Name='Description'>My new Description</Field></Method>" +
    "</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 = WssLists.UpdateListItems("List_Name", elBatch);

You can see on MSDN there are many web services available to interact with SharePoint.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜