SPList.AddItem method (String, SPFileSystemObjectType, String)
使用指定的檔案名稱中指定的資料夾清單中,會建立指定之類型的清單項目。
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
Public Function AddItem ( _
folderUrl As String, _
underlyingObjectType As SPFileSystemObjectType, _
leafName As String _
) As SPListItem
'用途
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
)
參數
folderUrl
Type: System.String伺服器相對 URL 的清單項目應建立所在的資料夾。URL 開頭應該是正斜線 ;例如, /sites/mysite/subweb/Lists/mylist/myfolder。
underlyingObjectType
Type: Microsoft.SharePoint.SPFileSystemObjectType其中一個指定的檔案系統物件,表示新的清單項目類型的列舉值。
leafName
Type: System.String檔案名稱,包括副檔名 ;例如, mydoc.doc。如需詳細資訊,請參閱 < Name屬性。
傳回值
Type: Microsoft.SharePoint.SPListItem
新的清單項目。
Exceptions
Exception | Condition |
---|---|
ArgumentOutOfRangeException |
備註
若要新增項目至清單,請先呼叫AddItem方法,以指定的檔案名稱中指定的資料夾建立指定類型的清單項目。若要指派特定的值,每個欄位的項目,然後傳回的SPListItem物件上使用索引器。最後,將變更寫入至資料庫SPListItem物件上呼叫Update方法。
重要
新的項目不會實際新增至清單上,直到您將它儲存到的內容資料庫呼叫SPListItem.Update方法。