Monday, December 14, 2009

Updating a list item by avoiding unnecessary call to event receiver.

If there is custom list and a event receiver[For creating/updating list item] is binded to that, then suppose we want to update the list without calling to the event receiver, then we have to disable the event firing and call the SystemUpdate() function instead of Update() function. Below here is the example in 2 steps:

Step 1:


class UpdateList: SPItemEventReceiver
{
}



Step 2:

SPListitem listItem = lst.Items.Add();
listItem["Title"] = "Samarendra Swain";
listItem["Company"] = "Manuh Solutions";

base.DisableEventFiring();
listItem.SystemUpdate();
base.EnableEventFiring();

No comments:

Post a Comment