Copied to clipboard

Flag this post as spam?

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


  • Chris Mahoney 139 posts 255 karma points
    Mar 25, 2015 @ 23:39
    Chris Mahoney
    0

    SQL DropDownList: How do I get the value?

    Hi,

    I've set up a SQL DropDownList, and as specified my SQL returns Value and Text fields.

    In my partial view macro I'm accessing @nameOfPage.nameOfSqlDropDown, but that's returning the text instead of the value. How do I get the value? The documentation doesn't appear to explain this (but please send me a link if I'm missing something).

    Thanks :)

    Umbraco 6.2.5, uComponents 6.0

  • Mads Krohn 200 posts 462 karma points c-trib
    Mar 26, 2015 @ 08:55
    Mads Krohn
    0

    Hi Chris

    Looking through the source of the SQL DropDownList data type, it should indeed be the selected value that is stored on save.
    Can you provide any more info of your current setup ?

    Cheers
    Mads

  • Chris Mahoney 139 posts 255 karma points
    Mar 26, 2015 @ 20:37
    Chris Mahoney
    0

    Apologies - it turns out that it was a data error that made it look like a uComponents error. It is indeed working like it should. Crisis averted :)

  • Mads Krohn 200 posts 462 karma points c-trib
    Mar 26, 2015 @ 22:39
    Mads Krohn
    0

    I'm glad to hear that :)

  • Chris Mahoney 139 posts 255 karma points
    Feb 16, 2016 @ 19:13
    Chris Mahoney
    0

    Amusingly, here I am a year later, trying to do the exact opposite.

    I can get the value through Razor (@item.myDropDown) but I can't figure out how to get the text! How do I do this? :)

  • Mads Krohn 200 posts 462 karma points c-trib
    Feb 16, 2016 @ 21:03
    Mads Krohn
    0

    Hi Chris

    Is this still Umbraco 6.2.5, uComponents 6.0 ?

    Cheers

  • Chris Mahoney 139 posts 255 karma points
    Feb 16, 2016 @ 21:04
    Chris Mahoney
    0

    Yep.

  • Mads Krohn 200 posts 462 karma points c-trib
    Feb 16, 2016 @ 21:16
    Mads Krohn
    100

    Ok.

    As far as I can tell from looking at the source, uComponents only store the value in the database.
    So, from what I can see, there is no way to retrieve the text directly.

    What you might be able to do though, is to get all the prevalues from the data type and then find the correct text based on the saved value.
    This should be doable by using the service api's and the data types guid.

    Note however, that it will involve database access and therefor normally isn't intended for frontend use.

    Hope this helps.

    Cheers

  • Chris Mahoney 139 posts 255 karma points
    Feb 16, 2016 @ 21:34
    Chris Mahoney
    0

    Thanks for that. It's a pity; the regular Umbraco dropdown allows you to get the text or the value easily, so I assumed that this "extended" one would do the same thing and that I was missing something obvious!

    I can probably get away with database access; there aren't many instances where I need to do this and the site is only for internal use so it shouldn't slow things down too much.

    Thanks for the pointers.

Please Sign in or register to post replies

Write your reply to:

Draft