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 7 posts 89 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é 58 posts 261 karma points
    Jan 17, 2020 @ 16:37
    Marc-André
    1

    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>
              }
            }
    
Please Sign in or register to post replies

Write your reply to:

Draft