共用方式為


SPList.AddItem method (String, SPFileSystemObjectType)

建立指定之類型的清單項目在清單中指定的資料夾。

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'宣告
Public Function AddItem ( _
    folderUrl As String, _
    underlyingObjectType As SPFileSystemObjectType _
) As SPListItem
'用途
Dim instance As SPList
Dim folderUrl As String
Dim underlyingObjectType As SPFileSystemObjectType
Dim returnValue As SPListItem

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

參數

  • folderUrl
    Type: System.String

    伺服器相對 URL 的清單項目應建立所在的資料夾。URL 開頭應該是正斜線 ;例如, /sites/mysite/subweb/Lists/mylist/myfolder。

  • underlyingObjectType
    Type: Microsoft.SharePoint.SPFileSystemObjectType

    其中一個指定的檔案系統物件,表示新的清單項目類型的列舉值。唯一有效類型是File和Folder。如果您傳遞任何其他值, SPListItem物件上呼叫Update方法時,會擲回例外狀況。

傳回值

Type: Microsoft.SharePoint.SPListItem
新的項目。

備註

此方法會呼叫folderUrl、 underlyingObjectType,與 null AddItem(String, SPFileSystemObjectType, String)方法。

若要新增項目至清單,請先呼叫AddItem方法,以自動產生的名稱與指定的資料夾內建立指定類型的清單項目。若要指派特定的值,每個欄位的項目,然後傳回的SPListItem物件上使用索引器。最後,呼叫Update方法,對資料庫認可的變更。

重要

新的項目不會新增至清單,直到您將它儲存到的內容資料庫呼叫SPListItem.Update方法。

請參閱

參照

SPList class

SPList members

AddItem overload

Microsoft.SharePoint namespace

Add(String, SPFileSystemObjectType)

FileSystemObjectType

Url