More in this section
Forums / General Discussions / Show News Title

Show News Title

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
2 posts, 0 answered
  1. Asif
    Asif avatar
    110 posts
    Registered:
    18 Nov 2010
    08 Dec 2010
    Link to this post
    Hi,
    I want to show the list of News Title. I am using the below code for it. I am getting an error "

    Unable to cast object of type 'Telerik.Cms.Engine.Data.ContentQuery' to type 'Telerik.Cms.Engine.IContent'.

    "
    I know this line has a casting issue "Telerik.Cms.Engine.IContent getCategoryForPRovider = (IContent)Manager.Content.GetContent();" Any solution?

    Telerik.News.NewsManager Manager = new Telerik.News.NewsManager("News");
            IList posts = Manager.Content.GetContent();
            List<IContent> results = new List<IContent>();
            foreach (Telerik.Cms.Engine.IContent post in posts)
            {
                string catName = post.GetMetaData("Title").ToString();
                if (catName == null || catName == string.Empty)
                    continue;
             
                Response.Write(catName);
                Telerik.Cms.Engine.IContent getCategoryForPRovider = (IContent)Manager.Content.GetContent();
                if (results.IndexOf(getCategoryForPRovider) < 0)
                {
                    results.Add(getCategoryForPRovider);
                }
            }
            return results;
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    10 Dec 2010
    Link to this post
    Hello Asif,

    You have to supply an index to GetContent() like GetCotentent()[0] or use foreach.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered