SPList.GetItemByIdSelectedFields method
Gets the list item with the specified identifier (ID) and includes only the values for the specified fields.
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'Declaration
Public Function GetItemByIdSelectedFields ( _
id As Integer, _
ParamArray fields As String() _
) As SPListItem
'Usage
Dim instance As SPList
Dim id As Integer
Dim fields As String()
Dim returnValue As SPListItem
returnValue = instance.GetItemByIdSelectedFields(id, _
fields)
public SPListItem GetItemByIdSelectedFields(
int id,
params string[] fields
)
Parameters
id
Type: System.Int32An ID of the item. The value of this parameter does not correspond to the index of the item within the collection of items for the list, but to the value of the ID property of the list item.
fields
Type: []A comma-delimited list of field names for which to get values. To retrieve the value of the ContentType property of the list item, you must also specify the ContentTypeId property of the item. To retrieve all field values, use the GetItemByIdAllFields(Int32) method.
Return value
Type: Microsoft.SharePoint.SPListItem
The list item, including data from the specified fields. If you try to access a field value that is not returned because it was not specified, SharePoint Foundation makes a round trip to the database to retrieve all the item's field values except for User fields or custom Lookup fields.
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | fields is null . |