How to programmatically delete items in a SharePoint list

I was looking for a way to programmatically delete items in a SharePoint list, and I found this great post by DevExpert:

http://www.devexpertise.com/2009/02/04/deleting-list-items-in-a-sharepoint-list/

The author outlines four incorrect methods for doing it, and one correct method.  It turns out that you need to use a For loop with a decrementing counter, like this:

<code>

for (int i = list.Items.Count - 1; i >= 0; i--) {
    list.Items.Delete(i);
}
</code>
Great post!
Advertisements

1 Response to “How to programmatically delete items in a SharePoint list”


  1. 1 Praveen September 27, 2010 at 5:23 am

    thanks …….helped me a lot !!!!!!!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




RSS Information Week Headlines

  • An error has occurred; the feed is probably down. Try again later.

RSS SharePoint Team Blog

  • An error has occurred; the feed is probably down. Try again later.

RSS InfoPath Team Blog

  • An error has occurred; the feed is probably down. Try again later.

RSS Joel Oleson Blog

  • An error has occurred; the feed is probably down. Try again later.

RSS Susan Hanley’s KM Blog

  • An error has occurred; the feed is probably down. Try again later.

Blog Stats

  • 350,836 hits

%d bloggers like this: