1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / radRotator for Generic_Content

radRotator for Generic_Content

3 posts, 0 answered
  1. Andrew
    Andrew avatar
    202 posts
    Registered:
    05 Jun 2009
    30 Jun 2009
    Link to this post
    I am trying to create a control that will rotate generic contect created in the system.
    I have managed to get it to display the name of the content. But can't get it to show the actual content itself.

    protected

     

    void Page_Load(object sender, EventArgs e)

    {

     

    ContentManager manager = new ContentManager("Generic_Content");

     

     

    IList dataSource = manager.GetContent();

    uxContentRotator.DataSource = dataSource;

    uxContentRotator.DataBind();

    }

     

     

    protected void uxContentRotator_ItemDataBound(object sender, RadRotatorEventArgs e)

    {

    (e.Item.FindControl(

     

    "uxContent") as Label).Text = ((IContent)e.Item.DataItem).GetMetaData("Content").ToString();

    }

     


    using this code i get the following error:

    Object reference not set to an instance of an object.
    on this line:
    Line 19:         (e.Item.FindControl("uxContent") as Label).Text = ((IContent)e.Item.DataItem).GetMetaData("Content").ToString();

    If i change GetMetaData("Content"). to GetMetaData("Name").
    It shows me the names and does not give me any errors.

    Anyideas what i need to use instead of "Content" to get it to work?

    Thanks
  2. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    30 Jun 2009
    Link to this post
    I believe Content is not a metadata item, you should be able to access it directly as a property of the IContent item:

    e.Item.FindControl("uxContent") as Label).Text = ((IContent)e.Item.DataItem).Content.ToString()

    let me konw if that doesn't work!
  3. Andrew
    Andrew avatar
    202 posts
    Registered:
    05 Jun 2009
    30 Jun 2009
    Link to this post
    That works.

    Thanks.

Register for webinar
3 posts, 0 answered