Export (0) Print
Expand All

SPList Class

SharePoint 2003

The SPList class represents a list on a SharePoint Web site.

System.Object

   Microsoft.SharePoint.SPList

Public Methods

The following table shows the public methods of the SPList class and a brief description of each.

Name Description
GetDistinctFieldValues Returns a two-dimensional object array of field values in which data duplication within a specified field in the list is eliminated and each value returned is unique.
GetItemByID Returns the item at the specified index in the collection of items contained within the list.
GetItems(Microsoft.SharePoint.SPQuery) Returns a collection of items from the list based on the specified query.
GetItems(Microsoft.SharePoint.SPQuery, String) Returns a collection of items from the list based on the specified query and view.
GetItems(Microsoft.SharePoint.SPView) Returns a collection of items from the list based on the specified view.
GetView Returns a view of the list based on the specified GUID.
SaveAsTemplate Saves the list as a template in the list template gallery and includes the option of saving with or without the data contained in the current list.
ToString Returns the title of the list.
Update Updates the database with changes made to the list.

Public Properties

The following table shows the public properties of the SPList class, the data type of each property, and a brief description of each.

Name Data Type Description
AllowDeletion Boolean Gets a Boolean value that indicates whether the list can be deleted.
AllowMultiResponses Boolean Gets or sets a Boolean value that specifies whether users are allowed multiple responses to the survey.
AnonymousPermMask Microsoft.SharePoint.SPRights Gets or sets the permissions for anonyomous users of the list.
Author Microsoft.SharePoint.SPUser Gets the user who created the list.
BaseTemplate Microsoft.SharePoint.SPListTemplateType Gets the list definition type on which the list is based.
BaseType Microsoft.SharePoint.SPBaseType Gets the base type for the list.
Created System.DateTime Gets the creation date and time for the list.
DefaultView Microsoft.SharePoint.SPView Gets the default view for the list.
DefaultViewUrl String Gets the URL for the default view of the list.
Description String Gets or sets the description for the list.
Direction String Gets or sets the direction of the reading order for the list.
EnableAttachments Boolean Gets or sets a Boolean value that specifies whether attachments can be added to items in the list.
EnableModeration Boolean Gets or sets a Boolean value that specifies whether Content Approval is enabled for the list.
EnableVersioning Boolean Gets or sets a Boolean value that specifies whether versioning is enabled for the document library.
EventSinkAssembly String Gets or sets the strong name of a file in the Global Assembly Cache (GAC) that provides an event handler for document library events.
EventSinkClass String Gets or sets the fully qualified name of a class that defines an event handler for document library events.
EventSinkData String Gets or sets an arbitrary string of properties for use by an event handler for document library events.
ExcludeFromTemplate Boolean Gets a Boolean value that indicates whether the content of the list is included when the site to which the list belongs is saved as a custom site template.
Fields Microsoft.SharePoint.SPFieldCollection Gets the collection of field objects that represents all the fields in the list.
Forms Microsoft.SharePoint.SPFormCollection Gets the collection of form objects that represent the forms used in creating, editing, or displaying items in the list.
Hidden Boolean Gets or sets a Boolean value that specifies whether the list is hidden.
ID System.Guid Gets the GUID that identifies the list in the database.
ImageUrl String Gets the URL for the icon that represents the list.
ItemCount Int32 Gets the number of items in the list.
Items Microsoft.SharePoint.SPListItemCollection Gets the collection of all items in the list.
LastItemDeletedDate System.DateTime Gets the date and time that an item in the list was last deleted.
LastItemModifiedDate System.DateTime Gets the date and time that an item, field, or property of the list was last modified.
Lists Microsoft.SharePoint.SPListCollection Gets the parent collection of lists to which the list belongs.
MultipleDataList Boolean Gets or sets a Boolean value that specifies whether the list in a Meeting Workspace site contains data for multiple meeting instances within the site.
OnQuickLaunch Boolean Gets or sets a Boolean value that specifies whether the list appears on the Quick Launch area of the home page.
Ordered Boolean Gets or sets a Boolean value that specifies whether the option to allow users to reorder items in the list is available on the Edit View page for the list.
ParentWeb Microsoft.SharePoint.SPWeb Gets the parent Web site for the list.
Permissions Microsoft.SharePoint.SPPermissionCollection Gets the collection of permission objects that represents all the permissions for the list.
PropertiesXml String Gets a fragment in Collaborative Application Markup Language (CAML) that specifies property values for the list.
ReadSecurity Int32 Gets or sets the Read security setting for the list.
RootFolder Microsoft.SharePoint.SPFolder Gets the folder that contains all the files used in working with the list.
SchemaXml String Gets the XML schema that defines the list.
ShowUser Boolean Gets or sets a Boolean value that specifies whether names of users are shown in the results of the survey.
Title String Gets or sets the displayed title for the list.
Version Int32 Gets the version number of the list.
Views Microsoft.SharePoint.SPViewCollection Gets the collection of view objects that represents all the views of the list.
WriteSecurity Int32 Gets or sets the Write security setting for the list.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread safe.

Remarks

A list consists of items, or rows, and columns, or fields, that contain data. Use the Items property to return the collection of items in the list, and use the Fields property to return the collection of fields in the list.

Various List properties, ParentList properties, and other properties or methods for classes in the Microsoft.SharePoint namespace return a list or collection of lists from a specific context. Otherwise, use the Lists property of either the SPWeb or SPList class to return an SPListCollection object that represents either the collection of lists in a site or the collection of parent lists for a list. Use an indexer to return a single list from the collection. For example, if the collection is assigned to a variable named myLists, use myLists[index] in C#, or myLists(index) in Visual Basic .NET, where index is the index number of the list in the collection, the display name of the list, or the GUID of the list.

Example

The following code example returns and displays items from a specified list where values in the "ProjectedValue" field are greater than 500.

After instantiating an SPQuery object, the example uses Collaborative Application Markup Language (CAML) to define criteria for the query, which is passed as parameter in the GetItems method. For information on CAML, see Introduction to Collaborative Application Markup Language (CAML).

In addition, the example uses indexers on each list item to return values from the specified fields.

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

Namespace: Microsoft.SharePoint

Platforms: Microsoft Windows Server 2003

Assembly: Windows SharePoint Services (in Microsoft.SharePoint.dll)

Security: Code Access Security

Show:
© 2015 Microsoft