I have a code-behind setup on my detail widget template of a Dynamic Module. The widget template displays a single PRODUCT content type.
I was able to pull back a single product on the Page_Load event of my code behind using the following code below.
var dc = (DynamicDetailContainer)
var p = ((Telerik.Sitefinity.DynamicModules.Model.DynamicContent)dc.DataSource);
When I examine my variable "p" it is of type DynamicContent. At this point I want to pull the individual field values of this content type, but after reviewing the API and am not sure how to do pull a single value.
HOW DO YOU PULL A SINGLE FIELD VALUE FROM A DYNAMICCONTENT OBJECT? For example, the TITLE of the specific piece of content.
If anyone has any ideas please let me know.
I got my answer...
I threw my post up on the Sitefinity Devs Google+ site an go an answer in a few minutes. Really starting to like Google+.
Anyways, I was missing a namespace (Telerik.Sitefinity.Model) in my code to expose the .SetValue() and .GetValue() as they are extension methods on the DynamicContent object. Thanks Daniel Plomp. :-)
Thanks for the reply.
I have reviewed the same code reference section under the Module Builder section. I found out I was missing a namespace in my code. Should be good to go now. Thanks.
Did anyone ever find any other way of getting the current dynamic content instance from the current page_load code behind other than searching for a control that its bound to?
var appUrl = VirtualPathUtility.ToAbsolute(
// remove the app path (exclude the last slash)
var relativeUrl = HttpContext.Current.Request.Url.AbsolutePath.Remove(0, appUrl.Length - 1);
// trim the page url - 8 characters in this case - testpage
itemUrl = relativeUrl.Remove(0, 8);
DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
Type pressReleaseType = TypeResolutionService.ResolveType(
Type newsreleasesType = TypeResolutionService.ResolveType(
//pass the ItemUrl to the method
var parentItem = dynamicModuleManager.Provider.GetItemFromUrl(pressReleaseType, itemUrl,