Hi, stuck again. Just trying to get the nvarchar text from a prevalue in a dropdown to show in a template, instead of the number. Anyone spare a snippet?
@{ var myValues = Model.FIELD; foreach(var id in myValues.Split(',')) { var myStringValue = umbraco.library.GetPreValueAsString(Convert.ToInt32(id)); <li>@myStringValue </li> } }
As a dufus, I learn best (although slowly) by doing first, learning after. I can see that this is working but I'm pretty sure there's no reason to have a foreach in there, since I only need to show the one value. I'm working on simplifying that now.
get prevalue text from dropdown
Hi, stuck again. Just trying to get the nvarchar text from a prevalue in a dropdown to show in a template, instead of the number. Anyone spare a snippet?
Thanks,
Matthew
Hi Matthew,
You should be able to get the prevalue text with:
- Carsten
Thank you Carsten. I had run across that and did finally get a version of that to do it, modifying a snippet from:
http://our.umbraco.org/wiki/reference/umbracolibrary/getprevalueasstring
Here's what my current version looks like:
As a dufus, I learn best (although slowly) by doing first, learning after. I can see that this is working but I'm pretty sure there's no reason to have a foreach in there, since I only need to show the one value. I'm working on simplifying that now.
Thanks again.
There, that's got it, for any other dufus following along:
is working on a reply...