Copied to clipboard

Flag this post as spam?

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


  • MB 273 posts 936 karma points
    Aug 31, 2020 @ 16:56
    MB
    0

    Split multiple choice dropdown with comma

    Wanting to splite the following

     var options = Model.Value<IEnumerable<string>>("robotMetaTagDropdown");
    
        foreach (var option in options)
        {
            @option
        }
    

    But if I do this:

    var options = Model.Value<IEnumerable<string>>("robotMetaTagDropdown").ToString().Split(",");
    

    I get the following error:

    cannot convert from 'string' to 'char'

    I've been digging throug Google but with no success. Has anyone comma separated the dropdown values from backend?

  • Amir Khan 1287 posts 2744 karma points
    Aug 31, 2020 @ 18:55
    Amir Khan
    0

    If you just get rid of this it should return split values by default in your loop: .ToString().Split(",")

    https://our.umbraco.com/documentation/getting-started/backoffice/property-editors/built-in-property-editors/Dropdown/

Please Sign in or register to post replies

Write your reply to:

Draft