Compartilhar via


GetDistinctFieldValues Method

The GetDistinctFieldValues method of the SPList class 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.

Parameters

field   A Microsoft.SharePoint.SPField object that represents the field.

columnItems   A two-dimensional object array that is passed as an out parameter and that returns the values.

Return Value

An unsigned 32-bit integer that specifies the number of field values represented in the array.

Remarks

The GetDistinctFieldValues method can only be used for Text fields.

Example

The following code example uses the GetDistinctFieldValues method to return a two-dimensional object array representing values from the Title field of a specified list and then iterates through the array to display unique values.

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