Display Item Fields

Display Item Fields


  • Areas within which the data entered into the system is controlled
  • The data template associated with an item defines which fields it has Grouped into Sections
  • The section and field names provided in the template match those shown in the Content Editor
  • Used to organize and control the amount and type of data entered into the system:
    • Organized by their field type
    • The field type corresponds to the editing control provided in the Content Editor

Controls featured in this example:

  • Sitecore Web Control
  • XSLT Rendering

Classes featured in this example:

  • Sitecore.Collections.FieldCollection
  • Sitecore.Context
  • Sitecore.Data.Fields.Field
  • Sitecore.Data.Items.Item

Display Item Fields C# Web Control Code

Sitecore.Data.Items.Item item = Sitecore.Context.Item;
if (item == null) return;
Sitecore.Collections.FieldCollection fields = item.Fields;
if (fields == null) return;

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold; width:100%; clear:both");
output.Write("C# Web Control Real-time Output");

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-size:small; width:100%; clear:both");
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold");
//using : for colon and   for space
output.Write("{0}: {1}", "Item", item.DisplayName);
output.RenderEndTag(); //P

foreach (Sitecore.Data.Fields.Field field in fields)
    if (!field.Name.StartsWith("__"))
        output.Write("{0}: {1}", field.Name, field.Type);
        output.RenderEndTag(); //Li

output.RenderEndTag(); //Ol
output.RenderEndTag(); //Div

Display Item Fields XSLT Rendering Code

<div style="font-weight:bold; width:100%; clear:both"> <br/>
<xsl:value-of select="'XSLT Rendering Real-time Output'"/>

<div style="font-size:small; width:100%; clear:both">
<p><b>Item: <sc:text field="title" select="$sc_item" disable-web-editing="true"/></b></p>
<xsl:for-each select="$sc_item/fields/field">
<xsl:when test="contains(./@key,'__')" >
      <!-- ignore system types -->

 <li><xsl:value-of select="./@key" />: <xsl:value-of select="./@type"/> </li>

Display Item Fields C# Web Control Output

  1. breadcrumb title: Single-Line Text
  2. xslt demo: Rich Text
  3. csharp web control code: Rich Text
  4. info: Rich Text
  5. menu tooltip: Single-Line Text
  6. sources: Rich Text
  7. title: Single-Line Text
  8. menu title: Single-Line Text
  9. xslt rendering code: Rich Text
  10. sublayout demo: Rich Text
  11. web control demo: Rich Text
  12. qr code: Image
  13. tiny url: Single-Line Text
  14. csharp user control code: Rich Text
  15. related topics: Multilist
  16. image: Image
  17. theme: Droplist
  18. abstract: Multi-Line Text

Display Item Fields XSLT Rendering Output

  1. breadcrumb title: Single-Line Text
  2. xslt demo: Rich Text
  3. csharp web control code: Rich Text
  4. info: Rich Text
  5. menu tooltip: Single-Line Text
  6. sources: Rich Text
  7. title: Single-Line Text
  8. menu title: Single-Line Text
  9. xslt rendering code: Rich Text
  10. sublayout demo: Rich Text
  11. web control demo: Rich Text
  12. qr code: Image
  13. tiny url: Single-Line Text
  14. csharp user control code: Rich Text
  15. related topics: Multilist
  16. image: Image
  17. theme: Droplist
  18. abstract: Multi-Line Text