More in this section

Forums / Developing with Sitefinity / EventsManager - Select Top X?

EventsManager - Select Top X?

3 posts, 0 answered
  1. Matthew
    Matthew avatar
    33 posts
    Registered:
    15 Dec 2008
    17 Jan 2009
    Link to this post
    I can't seem to figure out how to return just the top (x) # of records when using the .GetContent method.

    Here's my code:

    Telerik.Events.EventsManager eventsManager = new Telerik.Events.EventsManager("Events");

    IList events = eventsManager.Content.GetContent();

    Anyone figure this out? Thanks in advance!




  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    19 Jan 2009
    Link to this post
    Hi Matthew,

    Please give a try to the example below. It returns the last two items, sorted by Publication_Date metafiled.

    ContentManager contentManager = new ContentManager("Events"); 
    // get list of the last two items sorted by Publication_Date DESC 
    IList listOfAllitems = contentManager.GetContent(0, 2, "Publication_Date DESC"); 
    // return items by title 
    foreach (IContent contentItem in listOfAllitems) 
    Response.Write(contentItem.GetMetaData("Title").ToString() + "<br />"); 

    I hope this helps.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Matthew
    Matthew avatar
    33 posts
    Registered:
    15 Dec 2008
    19 Jan 2009
    Link to this post
    Perfect, thanks. I should have more closely at the overloads for that.. I totally missed 'max'.

    Thanks again!
Register for webinar
3 posts, 0 answered