SPList.AddItem - Méthode (String, SPFileSystemObjectType, String)

Creates a list item of a specified type with a specified file name in the specified folder in the list.

Espace de noms :  Microsoft.SharePoint
Assembly :  Microsoft.SharePoint (dans Microsoft.SharePoint.dll)

Syntaxe

'Déclaration
Public Function AddItem ( _
    folderUrl As String, _
    underlyingObjectType As SPFileSystemObjectType, _
    leafName As String _
) As SPListItem
'Utilisation
Dim instance As SPList
Dim folderUrl As String
Dim underlyingObjectType As SPFileSystemObjectType
Dim leafName As String
Dim returnValue As SPListItem

returnValue = instance.AddItem(folderUrl, _
    underlyingObjectType, leafName)
public SPListItem AddItem(
    string folderUrl,
    SPFileSystemObjectType underlyingObjectType,
    string leafName
)

Paramètres

  • folderUrl
    Type : System.String

    The server-relative URL of the folder where the list item should be created. The URL should begin with a forward slash; for example, /sites/mysite/subweb/Lists/mylist/myfolder.

  • leafName
    Type : System.String

    The file name, including the file extension; for example, mydoc.doc. For more information, see the Name property.

Valeur renvoyée

Type : Microsoft.SharePoint.SPListItem
The new list item.

Exceptions

Exception Condition
ArgumentOutOfRangeException

underlyingObjectType is neither File nor Folder.

Remarques

To add an item to a list, first call the AddItem method to create a list item of the specified type with the specified file name in the specified folder. 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.

Voir aussi

Référence

SPList classe

SPList - Membres

AddItem - Surcharge

Microsoft.SharePoint - Espace de noms

FileSystemObjectType

Url

Name