Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • LeszekP 27 posts 78 karma points
    Jul 22, 2015 @ 15:42
    LeszekP
    0

    Dropdown gives int not string (text)

    Hi,

    I am using Dropdown list https://our.umbraco.org/documentation/using-umbraco/backoffice-overview/property-editors/Built-in-Property-Editors-v7/DropDown-List

    and ContentService in MVC project. I get value from IContent like

    contentItem.GetValue<string>("tier")
    

    but it gives me int number not text value.

    Is ContentService unable to return text instead of int value?

    Umbraco 7.2.6.

  • LeszekP 27 posts 78 karma points
    Jul 22, 2015 @ 15:55
    LeszekP
    0

    The same is for the second option Dropdown list with published keys.

    Should not dropdown list as value use defined text items? AngularJS in umbraco Backoffice shows it uses int numbers as values, like 200, 201, etc.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jul 22, 2015 @ 16:07
    Dennis Aaen
    0

    Hi LeszekP,

    What if you are doing it something like this.

    contentItem.GetPropertyValue

    Like the documentation https://our.umbraco.org/documentation/using-umbraco/backoffice-overview/property-editors/Built-in-Property-Editors-v7/DropDown-List

    @if (Model.Content.HasValue("superHero"))
    {
        <p>@Model.Content.GetPropertyValue("superHero")</p>
    }
    

    Hope this helps,

    /Dennis

  • LeszekP 27 posts 78 karma points
    Jul 22, 2015 @ 16:15
    LeszekP
    0

    I am working with ContentService to get content node from Umbraco. And it has not got GetPropertyValue method.

    I checked it with IPublishedContent using Umbraco helper and it works.

    I think the text:

    Dropdown List Returns: String

    Displays a list of preset values. The value saved is a text value

    is misleading. As it is still saved as int (nodeid?) but when using publishedContent it returns text value not int.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies