While deleting an item I want to update another list.
Below is my code.
public override void ItemDeleting(SPItemEventProperties properties)
{
base.ItemDeleting(properties);
string listName = properties.ListTitle;
if (listName == "Training Instances")
{
using (SPSite site = new SPSite(properties.WebUrl))
{
using (SPWeb web = site.OpenWeb())
{
string title = properties.ListItem["Title"].ToString();
SPList trainingSubscriptionsList = web.Lists.TryGetList("Training Subscriptions");
SPQuery query = new SPQuery();
query.Query = "<Where><Eq><FieldRef Name='Training' /><Value Type='Text'>" + title + "</Value></Eq></Where>";
SPListItemCollection listItemCollection = trainingSubscriptionsList.GetItems(query);
foreach (SPItem ts in listItemCollection)
{
if (ts["Status"].ToString() == "Available")
{
ts["Status"] = "Pending";
}
}
}
}
}
}
The problem is the item get deleted but the update is not happening.
Any help is very much apperciated.
Thanks.
You have to update the item: