Copied to clipboard

Flag this post as spam?

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


  • Damien Holley 180 posts 541 karma points
    Sep 25, 2016 @ 08:01
    Damien Holley
    0

    Retrieving the values for a radiobutton data type

    Hi, Just wondering how you go about getting the string list of items from a radiobutton datatype. The only examples of this I could find are old and use deprecated methods.

  • Alex Skrypnyk 6148 posts 24097 karma points MVP 8x admin c-trib
    Sep 25, 2016 @ 08:53
    Alex Skrypnyk
    0

    Hi Damien,

    Did you try this code?

    @if (Model.Content.HasValue("miniFigure"))
    {
        var preValue = Umbraco.GetPreValueAsString(Model.Content.GetPropertyValue<int>("miniFigure"));
        <p>@preValue</p>
    }
    

    Read more - https://our.umbraco.org/documentation/getting-started/backoffice/property-editors/built-in-property-editors/radiobutton-list

    I hope it will help you!

    Thanks,

    Alex

  • Damien Holley 180 posts 541 karma points
    Sep 25, 2016 @ 12:20
    Damien Holley
    0

    Hi Alex, This is a datatype that is not in use on the CurrentPage/Model.

    Basically I have a pre-existing radiobutton datatype that needs to be read into a list on another page.

  • Alex Skrypnyk 6148 posts 24097 karma points MVP 8x admin c-trib
    Sep 25, 2016 @ 12:34
    Alex Skrypnyk
    0

    Hi Damien,

    So do you need to create radiobutton list on another page? Or read selected value on another page?

    Thanks,

    Alex

  • Damien Holley 180 posts 541 karma points
    Oct 03, 2016 @ 05:29
    Damien Holley
    0

    No, I need to basically use the radiobutton values to choose which types of pages to search for, on one page I do not have the radiobuttons themseleves and need to look at all options.

    So i just need the radiobutton values from a radiobutton type. Not a variable that is present on the currentpage.

  • Chris Wilson 100 posts 377 karma points
    Oct 03, 2016 @ 09:51
    Chris Wilson
    100

    If I understand you correctly; you want to get the Prevalues from an existing Datatype that you have set?

    If so, you can get Prevalues by using the DataTypeService as follows:

    Umbraco.DataTypeService.GetPreValueAsString(1001);
    

    Where 1001 = the ID of the DataType you wish to access.

    You can look this up in the back office, it's the integer on the end of the URL:

    DataTypeURL

    I find it's easier to put this value in a config file to reduce the number of magic strings in your code. It shouldn't change during the lifetime of your application.

  • Damien Holley 180 posts 541 karma points
    Nov 15, 2016 @ 05:41
    Damien Holley
    0

    Hey is there any way to programmatically find this number?

    I may want to export then import this setup and all the numbers get screwed around when you do that.

Please Sign in or register to post replies

Write your reply to:

Draft