SPWeb currentWeb = SPContext.Current.Web;
ClientContext ctx = new ClientContext(currentWeb.Url);
List loginList = ctx.Web.Lists.GetByTitle("Login");
ListItemCreationInformation newRecord = new
ListItemCreationInformation();
Microsoft.SharePoint.Client.ListItem item =
loginList.AddItem(newRecord);
item["Title"] = txtUserName.Text;
item["Password"] = txtPassWord.Text;
item.Update();
ctx.ExecuteQuery();
txtUserName.Text = "";
txtPassWord.Text = "";
strError += "Insertion Successful";
ClientContext ctx = new ClientContext(currentWeb.Url);
List loginList = ctx.Web.Lists.GetByTitle("Login");
ListItemCreationInformation newRecord = new
ListItemCreationInformation();
Microsoft.SharePoint.Client.ListItem item =
loginList.AddItem(newRecord);
item["Title"] = txtUserName.Text;
item["Password"] = txtPassWord.Text;
item.Update();
ctx.ExecuteQuery();
txtUserName.Text = "";
txtPassWord.Text = "";
strError += "Insertion Successful";
Check out this link too...
ReplyDeletehttp://mindstick.com/Articles/50c4e9b3-2190-4bbf-9e57-035f228f1516/?Insert,%20Update,%20Delete%20in%20SharePoint%202010%20list%20using%20Client%20Object%20Model
Its also having a wonderful explanation on Insert, Update, Delete in SharePoint 2010 list using Client Object Model.
Thanks