Copied to clipboard

Flag this post as spam?

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


  • Kyle Jorve 11 posts 94 karma points
    Jan 07, 2020 @ 00:40
    Kyle Jorve
    0

    Get All Possible Values in Dropdown

    Hi! I'm trying to get all the possible options in a dropdown list and put them in an enumerable variable in the front end code (.cshtml). I believe these are called prevalues? Not sure.

    There was a way to do this in Umbraco 7, but I can't find how to do this in 8. Halp?

  • Marc-André 63 posts 279 karma points
    Jan 17, 2020 @ 16:37
    Marc-André
    2

    Hi Kyle.

    This is how I make it works :

    @{
              var _dataTypeService = Services.DataTypeService;
              var blogCategories = (DropDownFlexibleConfiguration)_dataTypeService.GetDataType(1142).Configuration;
              foreach (var value in blogCategories.Items)
              {
                <option value="@value.Value">@value.Value</option>
              }
            }
    
  • Mark Drake 133 posts 457 karma points c-trib
    Oct 28, 2021 @ 05:09
    Mark Drake
    1

    Visual Studio wasn't smart enough to give me the namespace.

    @using Umbraco.Core.PropertyEditors;
    
Please Sign in or register to post replies

Write your reply to:

Draft