Web developers wiki ASP.NET Sitecore Sharepoint Kentico by Evident Interactive

If you want to diplay sitecore items from (for example) a multilist field in Sitecore, we have written an easy function. All you have to do is give the name of the field containing the guid(s). Note: this works only for the current Sitecore item, feel free to expand the method for more dynamic.

        /// <summary>
        /// Get a generic list with items based on the field <guidFieldName> in the current item
        /// </summary>
        /// <param name="guidFieldName">The name of the field containing the guid</param>
        /// <returns>List</returns>
        public static List<Item> GetItemList(string guidFieldName)
            // get current database and item
            Database database = Sitecore.Context.Database;
            Item currentItem = Sitecore.Context.Item;

            // split the different guids
            stringguidFieldName" title=" itemGuids = currentItem.Fields">guidFieldName"> itemGuids = currentItem.FieldsguidFieldName.Value.Split(new char[{'|'});

            // insert the single items in a generic list
            List<Item> itemList = new List<Item>();
            foreach (string itemGuid in itemGuids)
                itemList.Add(database.Items[new ID(itemGuid)]);

            // return the item list
            return itemList;

 © Evident Interactive BV