Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 886 posts 2415 karma points
    Nov 08, 2019 @ 07:44
    Claushingebjerg
    0

    check specific checkbox list value

    I have a checkboxlist in v8, and i need to check it for values and do something, if a specific checkbox is set...

    Iknow i can get the values by doing

    foreach(var s in Model.Value<IEnumerable<string>>("type")){
    <text>@s</text>
    }
    

    But how do i check if one of the values is "foo"?

  • Greg Jenson 24 posts 157 karma points
    Aug 26, 2020 @ 16:01
    Greg  Jenson
    1

    There is probably a more elegant way to to this, but I am at least getting the results I want:

    var team = Umbraco.Content(Guid.Parse("123456789"))
    .ChildrenOfType("teamMember")
    .Where(x => x.IsVisible());
    @foreach(var item in team) {
        foreach(var g in item.Value<IEnumerable<string>>("group")) {
            if( g == "foo" ) {
                <p>@item.Value("yourField")</p>
            }
        }            
    }
    

    If anyone has an improved response, I'd like to see it.

  • 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