Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi all,
I am trying to iterate through the contents of a MNTP that is found in a different doctype to the one being modeled. My current code is:
IPublishedContent varSettingsSite = Umbraco.ContentAtRoot().FirstOrDefault(x => x.ContentType.Alias == WtSettingsSite.ModelTypeAlias); IEnumerable<IPublishedContent> topnavLinks = varSettingsSite.Value("wtSettingsNavTop"); if (topnavLinks != null) { <ul> @foreach (var item in topnavLinks)
Unfortunately, I am receiving the "cannot implicitly convert type object to system.collections.generic.ienumerable
If I just make it a var, I cannot loop through it a few lines later.
Any thoughts?
You need to use below approach to get it converted from object to IEnumerable
var topnavLinks = varSettingsSite.Value<IEnumerable<IPublishedContent>>("wtSettingsNavTop");
I hope that helps you.
Regards,
Shaishav
https://www.digitallymedia.com
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
casting to Ienumerable<>
Hi all,
I am trying to iterate through the contents of a MNTP that is found in a different doctype to the one being modeled. My current code is:
Unfortunately, I am receiving the "cannot implicitly convert type object to system.collections.generic.ienumerable
If I just make it a var, I cannot loop through it a few lines later.
Any thoughts?
You need to use below approach to get it converted from object to IEnumerable
I hope that helps you.
Regards,
Shaishav
https://www.digitallymedia.com
is working on a reply...