More in this section

Forums / Developing with Sitefinity / Simple control to display single metafield of content

Simple control to display single metafield of content

2 posts, 0 answered
  1. Schneider
    Schneider avatar
    29 posts
    02 Nov 2008
    14 Dec 2008
    Link to this post
    Is there a simple control to display a single metafield of a content item?

    I try just updating the templates for the ContentView and the system craps itself looking for a repeater or content control ids etc, when we don't want a repeater/content, we just want a single meta field.
  2. valio b
    valio b avatar
    33 posts
    24 Sep 2012
    15 Dec 2008
    Link to this post
    Hi Schneider,

    First of all please excuse me if I misinterpreted your question. As far as I understand you are trying to show/display somehow metafield data associated with an IContent item.

    In the scenario you have described the system is most likely complaining as it expects a collection of ContentItems to be bound to a repeater.
    Please do make sure you are getting a single ContentItem, then hopefully it should all be sweet as.
    Implementing such control could be achieved by having a bit of code similar to the one below:

    public void DisplaySingleContentItem(IContent listItem) 
     String metafiledValueToDisplay = listItem.GetMetaData("Title") as String; 
             //Display logic goes in here 

    Hope, that will get you going!

    Kind regards,
    valio b
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
2 posts, 0 answered