Copied to clipboard

Flag this post as spam?

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


  • Nathan Reece 62 posts 376 karma points
    Apr 14, 2021 @ 02:37
    Nathan Reece
    0

    Umbraco 7 How to read dropdown values

    How do I read dropdown values of a data type in Umbraco 7?

    Can anyone help me out!!

    thanks in advance

  • David Armitage 505 posts 2073 karma points
    Apr 14, 2021 @ 03:20
    David Armitage
    100

    Hi Nathan,

    This come should help you.

    The ID would be the ID of the data type within Umbraco. To find this you will have to go into the data types section within Umbraco backend and click on the dropdown field. The ID can be seen in the edit url.

    @using Umbraco.Core;
    @using Umbraco.Core.Services;
    
    @{
       IDataTypeService dataTypeService = ApplicationContext.Services.DataTypeService;
       var prevalues = dataTypeService.GetPreValuesByDataTypeId(14950);
    }
    

    Kind Regards

    David

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Apr 14, 2021 @ 10:21
    Alex Skrypnyk
    1

    To read just one prevalue value you can use this method:

    var prevalue = Umbraco.GetPreValueAsString(id);
    

    Where id is prevalueId.

    Thanks,

    Alex

Please Sign in or register to post replies

Write your reply to:

Draft