SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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 have a list with 3 items. When I delete these 3 items and add new items they get ID 4, ID 5 and ID 6. But I want the new items to get ID 1, ID 2, and ID 3.

Is there any workaround?

This is how I am deleting the items.

 var typeList = web.Lists[Project.Players.List_PlayerType_Title];
 var sbDelete = new StringBuilder(); 
            sbDelete.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Batch>");   
            string command = "<Method><SetList Scope=\"Request\">" + typeList.ID + "</SetList><SetVar Name=\"ID\">{0}</SetVar><SetVar Name=\"Cmd\">Delete</SetVar></Method>";
             foreach (SPListItem item in typeList.Items)
                sbDelete.Append(string.Format(command, item.ID.ToString()));
            web.AllowUnsafeUpdates = true;
            web.RecycleBinEnabled = false;
            web.RecycleBinEnabled = true;
share|improve this question
How are you deleting the items? Check the recycle bins for the files if this is a Document Library – Robert Lindgren Jun 27 '13 at 9:36
I updated my question with my code – Rohander Jun 27 '13 at 9:44
up vote 0 down vote accepted

when you add items to the list if you leave the id field blank it will use the system generated ID, if you add the item programmatically you can assign an id to the list item.

the issue is that you will get duplicate ID's!

To get around this youll need to create a list event handler the runs the item adding event that gets triggered! in this event it needs to check (loop) through each number as it loops through the list! eg. 1 would be the start and it will check to see the items within the list if they have that id, if none does then assign that value, if an item in the list does have that id than move on to the next number in the list and so on!

You can change it in the Database! lol but it wouldnt recommend it! to check and doe the above look at this!

using the method I outlined plus this will give you the right result ;)

for spitem (id)

sorry Anuja but you can change it ;) just not ootb obviously!

share|improve this answer

When we add a new item in the list, ID column will automatically be created. ID is a system field, you can't change it. You can try to save the list as a template and create a new list based on the template.

share|improve this answer

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.