Wednesday, July 18, 2007

wss 3.0 - Deleting item from a list

This article gives a good idea about deleting an Item from a list. But upon using the given code, "Specified argument was out of the range of valid values". I got the collection of items into a listitemcollection and looped through the collection and deleted the item. There were around 506 items in the list initially and method stopped after deleting 255 items. The second run reduced the items to 125 after that to 60, 30, 15, 7 items. Pal suggested me delete the item by getting their ID instead of deleting them using the index. This did the trick and worked for me perfectly.

So while deleting an item from the list, get the item ids into an arraylist and delete the items in the ListItemCollection using the item id. This should do the trick and work beautifully.

No comments:

Post a Comment