Export (0) Print
Expand All

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)

public SPListItem GetItemByIdSelectedFields(
	int id,
	params string[] fields
)

Parameters

id
Type: System.Int32

An 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.

ExceptionCondition
ArgumentNullException

fields is null .

Show:
© 2014 Microsoft