Copied to clipboard

Flag this post as spam?

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

  • Lewis Smith 208 posts 617 karma points c-trib
    Mar 20, 2018 @ 12:19
    Lewis Smith

    Hi all,

    I'm trying to loop through a multiple list dropdown and I'm having issues.

    Everywhere online states that the returned value is a comma-separated list so I assumed a string would be returned which I could then loop through using a .Split(',') but this doesn't seem to work.

    If i do this i get the following outputs:

    System.Linq.Enumerable+WhereSelectArrayIterator`2[System.String System.String]

    I have followed the tutorial on

    Here is the code i have:

    var test = item.GetPropertyValue<string>("ringCategory");
    foreach (var cat in test.Split(','))

    I have also tried casting the item to an array thinking this may be an issue by both declaring the item as a

    Any help?!


  • Dennis Aaen 4499 posts 18232 karma points admin hq c-trib
    Mar 20, 2018 @ 12:57
    Dennis Aaen

    Hi Lewis,

    Can you try to use something like this:

      if (Model.Content.HasValue("ringCategory")){                                                     
          @foreach(var item in Model.Content.GetPropertyValue<string>("ringCategory").Split(',')) { 

    Please keep in mind that you change it so it match your case.

    Hope this helps,


  • Dan Diplo 1554 posts 6204 karma points MVP 5x c-trib
    Mar 20, 2018 @ 13:03
    Dan Diplo

    What version of Umbraco are you using?

    In theory you should be able to just do this:

    var values = GetPropertyValue<IEnumerable<string>>("ringCategory");

    This returns an array of strings.

    However, when I tried this in Umbraco 7.9.2 the collection was always empty. I think there must be a bug in this version.

    If you check your umbraco.config file in /App_Data/ can you see your ringCategory property on any of your documents?

  • Proxicode 127 posts 323 karma points
    Nov 20, 2018 @ 22:12

    Thanks Dan! I'm in 7.12.1 and it works as you described.

    if (Model.Content.HasValue("filterVals"))
        var filterValues = Model.Content.GetPropertyValue<IEnumerable<string>>("filterVals");
        if(filterValues != null && filterValues.Any())
            foreach(var item in filterValues)
                <dd class="label-sm">@item</dd>
Please Sign in or register to post replies

Write your reply to: