In a DD4T View I am trying to pick the value of Path of the keyword inside the Category.
foreach(var category in @Model.Categories)
{
if (category.Title.Contains("Taxonomy"))
{
str = category.Keywords[0].Path;
break;
}
}
but getting null in @Model.Categories.
Error: Object reference not set to instance of the object.
Although data exist in XML.
Please suggest.
I discovered this is an issue in DD4T. The work-around is quite simple: if you use the implementation of Component (or Page) as your model, rather than the interface, it works.
So start your view with:
@model DD4T.ContentModel.Component
Rather than
@model DD4T.ContentModel.IComponent
And try again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With