More in this section

Forums / Developing with Sitefinity / EventsManager and GetContent

EventsManager and GetContent

2 posts, 0 answered
  1. ColinBowern
    ColinBowern avatar
    20 posts
    12 Aug 2012
    29 Dec 2008
    Link to this post
    I'm trying to get a list of published events in a specific category.  I'm not even getting to the filter aspect because the GetContent method is returning nothing where as the GetEvents method returns stuff:

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

    Where am I going left?  Secondly - how do I apply the filter expression to the GetContent?  The blog post didn't give us any code examples.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    29 Dec 2008
    Link to this post
    Hi colinbo,

    Check out the code below. It will return all items from a specific category.

            //add category named "mycategory" 
            string category = "mycategory"
            //create a new instace of EventsManager 
            EventsManager eventsManager = new EventsManager("Events"); 
            //add filter here 
            List<IMetaSearchInfo> filter = new List<IMetaSearchInfo>(); 
            filter.Add(new MetaSearchInfo(MetaValueTypes.ShortText, "Category", category, SearchCondition.Equal, JoinType.And)); 
            //get list of all events items in "mycategory" category, listed by Title 
            IList listOfAllEvents = eventsManager.Content.GetContent(0, 0, string.Empty, nullstring.Empty, null, filter.ToArray()); 
            foreach (IContent eventItem in listOfAllEvents) 
                Response.Write(eventItem.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.
2 posts, 0 answered