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

Forums / Developing with Sitefinity / Adding Blog Post Titles to a Dropdown List

Adding Blog Post Titles to a Dropdown List

6 posts, 0 answered
  1. Randy Bauer
    Randy Bauer avatar
    67 posts
    Registered:
    25 Sep 2009
    11 Nov 2009
    Link to this post
    protected void Page_Load(object sender, EventArgs e)  
        {  
            if (!IsPostBack)  
            {  
                Telerik.Blogs.BlogManager blogManager = new Telerik.Blogs.BlogManager();  
                // get all blog posts  
                IList listOfPosts = blogManager.Content.GetContent();  
                if (listOfPosts.Count > 0)  
                {  
                    foreach (Telerik.Cms.Engine.IContent postItem in listOfPosts)  
                       ddlPosts.Items.Add(postItem.GetMetaData("Title"));  
                       Response.Write(newsItem.GetMetaData("Title") + "<br />");  
                }   
            }   
        } 

    I am trying to add the titles of the blog post to a dropdown list.  I can get this to work in VB, but I'm not a C# developer and this is giving me an error regarding invalid arguments.  Adding the items to the dropdown list fails, but doing a response write works.

    I'm thinking I may need to do a conversion, but not sure.

    Thanks,

    Randy

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    12 Nov 2009
    Link to this post
    Hello Randy Bauer,

    Try using the code shown below:

    protected void Page_Load(object sender, EventArgs e)
       {
           BlogManager manager = new BlogManager("Blogs");
           IList listOfAllPosts = manager.Content.GetContent();
           foreach (IContent cnt in listOfAllPosts)
           {
               string val = (string)cnt.GetMetaData("Title");
               ListItem item = new ListItem(val,val);
               DropDownList1.Items.Add(item);
           }
     
       }


    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Roopesh
    Roopesh avatar
    39 posts
    Registered:
    29 Oct 2010
    03 Nov 2010
    Link to this post
    Hello Team,
    How to get all blog categories ?

    Thank You
    Roopesh
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    03 Nov 2010
    Link to this post
    Hello Roopesh,

    There is a method of the manager - GetCategories()

    sample

    var manager = BlogManager("Blogs");
    var c = manager.GetCategories()


    Greetings,
    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
  5. Roopesh
    Roopesh avatar
    39 posts
    Registered:
    29 Oct 2010
    03 Nov 2010
    Link to this post
    Hello Ivan Dimitrov ,


    I am using asp.net 2008 and SF 3.7 . Can you give code in that?

    Thank you 
    Roops




    Posted 37 minutes ago

    Hello Roopesh,

    There is a method of the manager - GetCategories()

    sample

    var manager = BlogManager("Blogs");
    var c = manager.GetCategories()


    Greetings,
    Ivan Dimitrov 
    the Telerik team
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    03 Nov 2010
    Link to this post
    Hi Roopesh,

    Use ContentManager class

    var manager = new ContentManager(
    "Blogs");


    Greetings,
    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
Register for webinar
6 posts, 0 answered