Compartilhar via


GetItems(Microsoft.SharePoint.SPQuery) Method

The GetItems method of the SPList class returns a collection of items from the list based on the specified query.

Parameters

query   A Microsoft.SharePoint.SPQuery object that contains the query.

Return Value

A Microsoft.SharePoint.SPListItemCollection object that represents the items.

Example

The following code example uses the GetItems method to return and display items whose "Schedule" field value equals "2 weeks".

After instantiating an SPQuery object through a constructor, the example uses Collaborative Application Markup Language (CAML) to define criteria for the query, which is passed as parameter in the GetItems method.

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