开发者

C# sp2010 adding items to a list

ClientContext ctx = new ClientContext("http://sp2010Server/sites/mySite");  
Web web = ctx.Web;

ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();  
ListItem listItem = web.Lists.GetByTitle("Site Requests").Add开发者_开发百科Item(itemCreateInfo);  
listItem["Title"] = "title";  
listItem["Description"] = "description";  
listItem["Url"] = "someUrl";  
listItem.Update();

i have the above code to update a sp2010 list, but it never adds an item to the list. I manually created a list called "Site Requests" and want to add an item to this list. Am i doing this right? I do not get any errors, code executes fine but no new item in the list.


Please see:

http://msdn.microsoft.com/en-us/library/ee539976.aspx

ClientContext clientContext = new ClientContext("http://sp2010Server/sites/mySite");
SP.List oList = clientContext.Web.Lists.GetByTitle("Site Requests");

ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();
ListItem oListItem = oList.AddItem(itemCreateInfo);
oListItem["Title"] = "title";
oListItem["Description"] = "description";
oListItem["Url"] = "someUrl";

oListItem.Update();

clientContext.ExecuteQuery(); 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜