Did this article resolve your question/issue?


Your feedback is appreciated.

Please tell us how we can make this article more useful. Please provide us a way to contact you, should we need clarification on the feedback provided or if you need further assistance.

Characters Remaining: 1025



Related Data API not working in a widget template

« Go Back


Article Number000097900
EnvironmentProduct: Sitefinity
Version: 7.x, 8.x, 9.x, 10.x, 11.x, 12.x
OS: All supported OS versions
Database: All supported Microsoft SQL Server versions
Question/Problem Description
The following piece of code is failing in an MVC widget template:
DynamicContent result = ...


var image = result.GetRelatedItems<Image>("Image").FirstOrDefault();

How to get the related image using the Related Data API?
Steps to Reproduce
Clarifying Information
Error MessageCompiler Error Message: CS1061: 'Telerik.Sitefinity.DynamicModules.Model.DynamicContent' does not contain a definition for 'GetRelatedItems' and no extension method 'GetRelatedItems' accepting a first argument of type 'Telerik.Sitefinity.DynamicModules.Model.DynamicContent' could be found (are you missing a using directive or an assembly reference?)
Defect/Enhancement Number
There is no reference to the namespace that contains the RelatedDataExtensions class, which contains the GetRelatedItems extension method.
Include the following reference along with the other "using" statements in the view:
@using Telerik.Sitefinity.RelatedData
Last Modified Date8/13/2019 2:21 PM