There are 2 ways by which the SpListItem data can be updated.
The below snippet is usually used to update SPListItems.
SpListItem.Update() :
The Item.Update() updates the database with the changes, creates a new version and changes the Modified and Modified By fields.
SPList list = web.Lists["myList"];
SPListItem item = list.Items[0]; // First item in the list
item["myField"] = “Test update”;
item.Update();
list.Update();
SpListItem.SystemUpdate() :
If you want to avoid version changes, Modified and Modified By fields from getting updated , Item.SystemUpdate() would be the right way to do it.
SPList list = web.Lists["myList"];
SPListItem item = list.Items[0];
item["myField"] = “Test update”;
item.SystemUpdate(false);
list.Update();
The argument false informs the SP object Model not increment versions.
Wednesday, May 27, 2009
Sunday, May 24, 2009
ItemUpdating - Fetching the updated field value on itemupdating event
I'm overriding the ItemUpdating event, here I have a field "Start Date" . Now when user edits the Start date of an item and clicks "OK",I need to capture the previous and latest start date value and compare them.
I'm able to get the previous date and the current date value by the following code

For futher details have a look into this link below
http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/fc56a0f9-9688-479f-b984-5ee3809e72cb/#bb83182a-1322-41e8-bc97-f5a59d4f5dc4
I'm able to get the previous date and the current date value by the following code

For futher details have a look into this link below
http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/fc56a0f9-9688-479f-b984-5ee3809e72cb/#bb83182a-1322-41e8-bc97-f5a59d4f5dc4
Subscribe to:
Posts (Atom)