Modifying NewsRotator Sample to use custom field image selector - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Modifying NewsRotator Sample to use custom field image selector

  • Modifying NewsRotator Sample to use custom field image selector
  • Problem:
    The problem I am having is that I am not able to retrieve a custom field value added to the News module. I am trying to retreive the value  in the RadRotator1_ItemDataBound event.

    To use a thumbnail selector added to the News Module, in combination with the SDK NewsRotator Sample. I successully implemented a thumbnail selector as a custom field by following the article:

    I then modified the dataSource in the NewsRotator Sample

    Old DataSource


    var dataSource = App.WorkWith().NewsItems()  

    .Where(n => n.Status ==  ContentLifecycleStatus.Live)





    .Where(i => i.Parent.Title == "Thumbnails" && i.Status == ContentLifecycleStatus.Live),

     item => item.Title.Value,

    image => image.Title.Value,

    (item, image) =>

     new NewsItem = item, NewsImage = image   


    New DataSource


    var dataSource = App.WorkWith().NewsItems()

    .Where(n => n.Status == ContentLifecycleStatus.Live)


    After modify the datasource the line of code that gets the news item in RadRotator1_ItemDataBound stopped working. I'm not sure if the following was the correct thing to do, however, it did get rid of an error. I changed the following line of code.

    Old line of code

    NewsItem newsItem = (NewsItem)TypeDescriptor.GetProperties(e.Item.DataItem)["NewsItem"].GetValue(e.Item.DataItem);


    New line of code

    NewsItem newsItem = (NewsItem)e.Item.DataItem;

    At this point the NewsRotator is functional except that it does not display images.

    Where it's not working
    In RadRotator1_ItemDataBound I added the following code

    (newsItem.GetValue("Thumbnail") != null)

        string thumbnail = newsItem.GetValue("Thumbnail").ToString();

    The problem is that newsItem.GetValue("Thumbnail") is always returning null.

  • I found the problem but will leave the thread open in case I have any more question.

    Instead of this:



    Use this: