Copied to clipboard

Flag this post as spam?

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

  • Claushingebjerg 937 posts 2572 karma points
    Nov 08, 2019 @ 07:44

    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")){

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

  • Adrian 3 posts 71 karma points
    Apr 15, 2020 @ 07:13

    I am sure this could be better but this is working for me. I only have a couple roles setup so an if condition like this isn't much trouble.

    foreach(var person in people){
        var roles = person.Value<IEnumerable<string>>("memberRoles");
        foreach(var role in roles){
            if(role == "Site Selection"){
  • Greg Jenson 24 posts 157 karma points
    Aug 26, 2020 @ 16:01
    Greg  Jenson

    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"))
    .Where(x => x.IsVisible());
    @foreach(var item in team) {
        foreach(var g in item.Value<IEnumerable<string>>("group")) {
            if( g == "foo" ) {

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

  • louisjrdev 11 posts 84 karma points
    Nov 29, 2021 @ 13:40


    if(Model.Value<IEnumerable<string>>("type").Any(x => x == "foo")){
        //My conditional logic if value is "foo"
Please Sign in or register to post replies

Write your reply to: