Sitecore 5.0 API

FieldList Class

Represents the fields in an item.

For a list of all members of this type, see FieldList Members.

System.Object
   Sitecore.Collections.FieldList

[Visual Basic]
Public Class FieldList
    Implements ICollection, IEnumerable
[C#]
public class FieldList : ICollection, IEnumerable

Thread Safety

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 field is a single value in an item. The template of an item defines which fields an item has. The value of a field is always a string, but a the type of a field determines the semantics of the value. A field always has a name and an ID that uniquely identifies the field.

Fields can be retrieved either by ID, name, or index in the field collection.

By default the field list only contains the fields that have a value. Blank fields are omitted. To populate the list with all the fields defined by the template use the ReadAll method.

To sort the fields in the order by which they appear in the Sitecore client use the Sort method.

Example

This example gets the french text field of an item.

public string GetFrenchText(ID id) {
  Language language = Language.Parse("fr");

  Item item = Sitecore.Context.Database.Items[id, language];

  if (item != null) {
    return item["Text"];
  }

  return "";
}

Requirements

Namespace: Sitecore.Collections

Assembly: Sitecore.Kernel (in Sitecore.Kernel.dll)

See Also

FieldList Members | Sitecore.Collections Namespace