Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
GetItems Method (SPView)
Collapse the table of content
Expand the table of content

SPList.GetItems Method (SPView)

Windows SharePoint Services 3

Returns a collection of list items from the list based on the specified view.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

public SPListItemCollection GetItems(
	SPView view


Type: Microsoft.SharePoint.SPView
An SPView object that represents the view.

Return Value

Type: Microsoft.SharePoint.SPListItemCollection
An SPListItemCollection object that represents the list items.

The following code example shows uses the GetItems method to return items from a list according to the specified view.

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

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

SPSite oSiteCollection = SPContext.Current.Site;
SPList oList = oSiteCollection.AllWebs["Site_Name"].Lists["List_Name"];
SPView oListView = oList.Views["View_Name"];

SPListItemCollection collListItems = oList.GetItems(oListView);

foreach (SPListItem oListItem in colListItems)
    Label1.Text += 
        + " -- " + 
        + "<BR>";

Community Additions

© 2015 Microsoft