Compartir a través de


GetItemById Method

The GetItemById method of the SPList class returns the list item with the specified integer ID.

Parameters

id   A 32-bit integer that identifies 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 SPListItem class.

Return Value

A Microsoft.SharePoint.SPListItem object that represents the item.

Example

The following code example uses the GetItemById method to return the fourth item from a list and display specified field values of the item.

This example requires using directives (Imports in Visual Basic) for the Microsoft.SharePoint, Microsoft.SharePoint.Utilities, and Microsoft.SharePoint.WebControls namespaces.

The example assumes the existence of a .aspx page that contains a label control.

Requirements

Platforms: Microsoft Windows Server 2003

Security: Code Access Security