public static string GetFieldValue(Sitecore.Data.Templates.TemplateField field, Item item) { switch (field.Type.ToLower()) { case "tristate": return("TriState"); case "checkbox": return(item.GetCheckBoxValueByFieldName(field.Name).ToString()); case "date": DateField dateField = item.Fields[field.Name]; return(dateField.DateTime != DateTime.MinValue ? dateField.DateTime.ToString("d") : string.Empty); case "datetime": DateField datetimeField = item.Fields[field.Name]; return(datetimeField.DateTime != DateTime.MinValue ? datetimeField.DateTime.ToString("g") : string.Empty); case "number": return(item.Fields[field.Name].Value); case "integer": return(item.Fields[field.Name].Value); case "treelist with search": case "treelist": case "treelistex": case "treelist descriptive": case "checklist": case "multilist with search": case "multilist": var items = item[field.Name].GetMultiListParameterItems(); return(items != null?string.Join(", ", items.Select(x => x.DisplayName)) : string.Empty); case "grouped droplink": case "droplink": case "lookup": case "droptree": case "reference": case "tree": return(item.GetPropertyAsItem(field.Name)?.DisplayName); case "file": FileField fileField = item.Fields[field.Name]; return(fileField.MediaItem.DisplayName); case "image": ImageField imgField = item.Fields[field.Name]; return($"<img src=\"{imgField.MediaItem.GetImageUrl()}\" alt=\"{imgField.Alt}\" class=\"content-image\" />"); case "general link": case "general link with search": case "custom general link": LinkField linkField = item.Fields[field.Name]; return($"<a href=\"{linkField.GetGeneralLinkUrl()}\" target=\"{linkField.GetTarget()}\" >{linkField.Title}</a>"); case "password": case "icon": case "rich text": case "html": case "single-line text": case "multi-line text": case "frame": case "text": case "memo": case "droplist": case "grouped droplist": case "valuelookup": return(item.Fields[field.Name].Value); } return(string.Empty); }