Getting Data from a Dynamic Module

Posted by Community Admin on 04-Aug-2018 21:02

Getting Data from a Dynamic Module

All Replies

Posted by Community Admin on 06-Mar-2013 00:00

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

Posted by Community Admin on 06-Mar-2013 00:00

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

Posted by Community Admin on 06-Mar-2013 00:00

Thanks!  I knew I was doing something stupid.  Completely forgot that namespace.

This thread is closed