Partilhar via


SPList.AddItem Method

Creates a list item in the root folder of the list.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

Syntax

'Declaration
Public Function AddItem As SPListItem
'Usage
Dim instance As SPList
Dim returnValue As SPListItem

returnValue = instance.AddItem()
public SPListItem AddItem()

Return Value

Type: Microsoft.SharePoint.SPListItem
The new item.

Remarks

To add an item to a list, first call the AddItem method to create a nonfolder list item with an automatically generated name in the root of the list. Then use indexers on the returned SPListItem object to assign specific values for each field of the item. Finally, call the Update method on the SPListItem object to write the changes to the database.

Important

The new item is not actually added to the list until you save it to the content database by calling the SPListItem.Update method.

See Also

Reference

SPList Class

SPList Members

AddItem Overload

Microsoft.SharePoint Namespace

Add()