Retrieving Treelists

Retrieving Treelists

This snippet uses a fields collection to reference the field

  • Returns null if the field does not exist or the field value is null
  • Does not generate inline editing controls for the Page Editor
  • Useful for field types other than simple field types

  • C# Web Control Code

    Sitecore.Data.Items.Item item = Sitecore.Context.Item;

    Sitecore.Data.Fields.MultilistField multilistField = item.Fields["TreeListField"];

    Sitecore.Data.Items.Item[] items = multilistField.GetItems();