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 1289 posts 2746 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/

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies