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
I am working in the backend of umbraco with the IContentService API and I need to read the dropdown selected string value of a combo.
I have an IContent object representing the object I am working with. I have a dropdown called "Brand" and when I do:
var brand = content.GetValue
it does not return the selected string value visible in the UI, rather a number, in this case 231 and I don't what this refers to or how to get the selected string value.
can you show us the complete code of where you want to access this Brand property?
Also which version are you using of Umbraco?
The code is simply this:
var brand = content.GetValue("Brand");
//brand returns 231 but I need the selected string value of the combo
Where content is the correct IContent object that I want to work with.
var brand = content.GetValue<string>("Brand");
Hope this helps!
OK found the answer just need to use umbraco.GetPreValueAsString(231)
Here's what I did on umbraco 7.14.0:
/// Returns the value of a drop down property.
/// <param name="page">
/// The page with the drop down property.
/// <param name="propName">
/// The name of the drop down property.
/// The drop down text value.
private static string GetDropDownValue(IContent page, string propName)
var dtService = ApplicationContext.Current.Services.DataTypeService;
var valueId = page.GetValue<int?>(propName);
That's more just a note to myself in case I search for this again in the future.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted