/// <summary> /// Prints individual parameters of a reference item. /// </summary> /// <param name="oHtmlTextWriter">The o HTML text writer.</param> /// <param name="referenceItem">The reference item.</param> private void addParameters(HtmlTextWriter oHtmlTextWriter, ReferenceItem referenceItem) { if (referenceItem.Parameters.Count() > 0) { oHtmlTextWriter.RenderBeginTag(HtmlTextWriterTag.Tr); oHtmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Colspan, "2"); oHtmlTextWriter.RenderBeginTag(HtmlTextWriterTag.Th); oHtmlTextWriter.Write(referenceItem.Name); oHtmlTextWriter.RenderEndTag();//th oHtmlTextWriter.RenderEndTag();//tr } foreach (var param in referenceItem.Parameters) { oHtmlTextWriter.RenderBeginTag(HtmlTextWriterTag.Tr); oHtmlTextWriter.RenderBeginTag(HtmlTextWriterTag.Td); oHtmlTextWriter.Write(param.Title); oHtmlTextWriter.RenderEndTag();//td oHtmlTextWriter.RenderBeginTag(HtmlTextWriterTag.Td); var value = param.Value; switch (param.Type) { case "Dropdown": { var friendlyValue = param.PossibleValues().FirstOrDefault(v => v.Value == value); if (friendlyValue != null) { value = friendlyValue.Name; } } break; case "Item Selector": { var item = this.Db.GetItem(param.Value); if (item != null) { value = item.Paths.FullPath; } } break; case "Date picker": value = DateUtil.FormatIsoDate(param.Value, "dd/MM/yyyy hh:mm"); break; } oHtmlTextWriter.Write(value); oHtmlTextWriter.RenderEndTag();//td oHtmlTextWriter.RenderEndTag(); } }
private void PopulateAvailableColumns() { var handle = UrlHandle.Get(); var itemUri = ItemUri.Parse(handle["id"]); var item = Sitecore.Data.Database.GetItem(itemUri); if (item == null) return; try { var referenceItem = new ReferenceItem(item); var viewer = BaseViewer.Create(referenceItem.FullType, string.Empty); if (viewer == null) return; foreach (var availableColumn in viewer.AvailableColumns) { ColumnName.Controls.Add(new ListItem { Header = availableColumn, Value = availableColumn.ToLowerInvariant()}); } } catch (FileNotFoundException) { //todo } }