Monday, April 19, 2010

Your changes conflict with those made concurrently by another user. If you want your changes to be applied, click Back in your Web browser.

Today I am facing save conflict problem when i am updating list item during itemupdating event.

I have found solution after Research.

using (SPSite oSiteCollection = new SPSite(properties.WebUrl.ToString()))
{
using (SPWeb oWebsiteRoot = oSiteCollection.OpenWeb())
{
int count = 0;
oWebsiteRoot.AllowUnsafeUpdates = true;

SPList list = oWebsiteRoot.Lists[properties.ListId];
SPListItem oItem = list.GetItemById(properties.ListItemId);
if (oItem["Request_x0020_Counter"] != null && oItem["Request_x0020_Counter"].ToString() != string.Empty)
{
count += Convert.ToInt32(oItem["Request_x0020_Counter"].ToString()) + 1;
}
else
{
count += count + 1;
}
properties.AfterProperties["Request_x0020_Counter"] = count;



}
}