We can easily add,update,delete sharepoint list item .The below code will show how to do these three operation on sharepoint list, using Sharepoint Server Object Model .
try
{
//Get the current web object
SPWeb _web = SPContext.Current.Web;
_web.AllowUnsafeUpdates = true;
//Get the List Object
SPList _mylist = _web.Lists["MyList"];
//Add a new item into list
SPListItem addItem =
_mylist.Items.Add();
addItem["Title"] = "Adding New Item";
addItem["Name"] = "Sandeep";
addItem.Update();
//Get list Item ID
int itemId = addItem.ID;
//Update list item using Item ID
SPListItem updateItem =
_mylist.GetItemById(itemId);
updateItem["Name"] = "Sandeep Nandey";
updateItem.Update();
//Delete List Item using ID
SPListItem deleteItem =
_mylist.GetItemById(itemId);
deleteItem.Delete();
_web.AllowUnsafeUpdates = false;
}
catch (Exception
Ex)
{
lblMessage.Text = Ex.Message;
}