Copied to clipboard

Flag this post as spam?

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


  • Tim C 161 posts 528 karma points
    May 19, 2016 @ 11:22
    Tim C
    0

    Dropdown text not value in template (custom property editor)

    When using a default Umbraco dropdown on a document type, if I then show its value on the template eg

    @Umbraco.Field("Category")

    it correctly shows me the 'Text' of the selected item even though it saves the arbitrary value in the underlying database.

    That is, the template somehow looks up the value from the prevalues and shows that.

    I have created a custom property editor for a drop down with prevalues where I specfiy the value for each option in the controller.

    Now showing this field in the template displays the value eg "1" rather than the selected text eg "Category a"

    Is there any way of programatically retrieving the prevalues so I can do a conversion in the template or am I resigned to hard coding this?

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Jul 22, 2016 @ 15:39
    Alex Skrypnyk
    0

    Hi Tim,

    Maybe this can help you:

    umbraco.library.GetPreValueAsString(Convert.ToInt32(id))
    

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft