Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Add item to list - just adds the last item

$
0
0

Hi,

I'm using a very simple code to add items to a list.

In debug I see all the item being added and calling Update, but at the end only the last one is actually added to the list.

The code is as follows:

SPList list = oSPWeb.Lists["ActivitiesList"];                       
SPListItem itemToAdd = list.Items.Add();
foreach (Activity act in activitiesList)
{
 itemToAdd["Title"] = act.Description;
 itemToAdd.Update();
}

Thanks,

DD


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>