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

Forums / Developing with Sitefinity / Getting Data from a Dynamic Module

Getting Data from a Dynamic Module

3 posts, 0 answered
  1. Forrest
    Forrest avatar
    3 posts
    Registered:
    03 Aug 2012
    06 Mar 2013
    Link to this post

    Hi All,

    I'm currently writing some code to tie into the dynamic content creating event which is working fine and is pasted below.  Essentially it creates a role for each piece of dynamic content (its going to be eventually tied to ecommerce).  What I'd like to do is after creating the role go ahead and create the ecommerce product however I'm having trouble getting the actual data of the dynamic model object (name, description, price).  Any ideas on the proper way to go about doing this? 

     

    public void CourseEventsHandler(IDynamicContentCreatedEvent eventInfo)
    {
        var dynamicContentItem = eventInfo.Item;
        var role = Convert.ToString(dynamicContentItem.UrlName);
        CreateRole(role);
    }

    Thanks!

    Jason

  2. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    06 Mar 2013 in reply to Forrest
    Link to this post

    Hey Jason,

    I understand you need the properties of the DynamicContent Item? You can just use the extension methods GetValue or GetValue<T>. They are living in the Telerik.Sitefinity.Model namespace.

    public void CourseEventsHandler(IDynamicContentCreatedEvent eventInfo) {
                 
       var dynamicContentItem = eventInfo.Item;
       var role = Convert.ToString(dynamicContentItem.UrlName);
       CreateRole(role);
     
       // Get the data out of the DynamicContentItem
        var title = dynamicContentItem.GetValue("Title").ToString();
     }

    Kind regards,
    Daniel

  3. Forrest
    Forrest avatar
    3 posts
    Registered:
    03 Aug 2012
    06 Mar 2013 in reply to Daniel Plomp
    Link to this post
    Thanks!  I knew I was doing something stupid.  Completely forgot that namespace.
3 posts, 0 answered