SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to check If deleted item is the Last Item deleted in the List in following method,

public override void ItemDeleted(SPItemEventProperties properties)


I know I can get web url using properties.WebUrl and then find list and then items count in it, but is there any better way of doing it ?

If item wasn't the last one then I can go through all List Items to find the List Item that was added nearest to DateTime.Now, but then I Can go through each list item and compare there dates, Does anyone knows any efficient way ?


I find LastItemModifiedDate property to get last item, so don't need to go through each list item to find the latest added to the list


I said I can get Last Item, but in real I am able to get last Item modified date, so only thing I know is to go through all items to find one I want :S, I bet there will be a better way

share|improve this question
up vote 1 down vote accepted

To find if it's the last item I would use:

properties.List.ItemCount < 1

But to get the last modified item I would consider using a query:

SPQuery q = new SPQuery();
q.query="<OrderBy><FieldRef Name='Modified' Ascending='False'></FieldRef></OrderBy>";
SPListItemCollection results = properties.List.GetItems(q);
//Last item should be the only entry in results. If no entries, then no items in list.

Note: I'm not sure about the sort order on the OrderBy - but I think descending will get the latest modified item.

share|improve this answer

There is a property called ID in SPListItem, that property contains the item's 1-based integer ID, which is one greater than the ID of the item that was previously added. If the item is deleted, its ID is not reuse. check this link in MSDN for further explanation.

Technically to get last item added is to get biggest ID in SPListItem.

share|improve this answer
The highest ID is the most recently created item, not necessarily the most recently modified. – Andy Burns Jul 26 '12 at 10:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.