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;
  • How are you deleting the items? Check the recycle bins for the files if this is a Document Library Commented Jun 27, 2013 at 9:36
  • I updated my question with my code
    – Rohander
    Commented Jun 27, 2013 at 9:44

2 Answers 2


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!


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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