Step 1: Create
New Project. (Minimum .NET Framework 3.5)
Step 2: Add
“Microsoft.SharePoint.Client” and “Microsoft.SharePoint.Client.Runtime”
namespaces.
Step 3: Write
the following code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//SharePoint namespace
using Microsoft.SharePoint.Client;
namespace UpdatingListItem
{
class Program
{
static void Main(string[]
args)
{
string
siteUrl = "http://sharepointserver.com";
ClientContext
clientContext = new ClientContext(siteUrl);
clientContext.Credentials = new System.Net.NetworkCredential("admin", "password",
"sharepointserver.com");
Web
site = clientContext.Web;
//Getting
List
List
list = site.Lists.GetByTitle("Students");
//Getting
List item
ListItem
listItem = list.GetItemById(2);
//Updating
List item
listItem["First
Name"] = "Hrithik";
listItem["Last
Name"] = "Roshan";
listItem["Age"]
= 37;
listItem.Update();
clientContext.ExecuteQuery();
Console.WriteLine("List Item Updated Successfully");
Console.ReadLine();
}
}
}
Very informative and worthy post. Thanks for the sharing such a precious updates with us.
ReplyDeleteAsus - Vivobook 15.6" Touch-Screen Laptop - 8GB Memory - 500GB Hard Drive - Black (V500CA-DB71T)
Asus - 15.6" Laptop - 6GB Memory - 750GB Hard Drive - Black