Copied to clipboard

Flag this post as spam?

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


  • Edgar Rasquin 326 posts 925 karma points
    Sep 26, 2017 @ 10:53
    Edgar Rasquin
    1

    Get checkbox values

    Hi there,

    I have a really simple issue: I'm trying to receive the values from a checkbox list like so:

    foreach (var item in project.GetPropertyValue<string>("projectCategories").Split(',')){<p>@item</p>}
    

    But I end up getting the following output instead of the expected values:

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

    I cant see where I'm going wrong...

    Any ideas?

  • Tobias Klika 101 posts 570 karma points c-trib
    Sep 26, 2017 @ 13:04
    Tobias Klika
    0

    What does

    <pre>@project.GetPropertyValue<string>("projectCategories")</pre>
    

    output? So you can get a better look at the saved value instead of trying to split it directly.

  • Edgar Rasquin 326 posts 925 karma points
    Sep 26, 2017 @ 13:08
    Edgar Rasquin
    0

    This is the direct Output value:

    System.Linq.Enumerable+WhereSelectArrayIterator`2[System.String,System.String] 
    
  • Tobias Klika 101 posts 570 karma points c-trib
    Sep 26, 2017 @ 13:20
    Tobias Klika
    101

    Looks like your values aren't stored as a string, but as an IEnumerable.

    Try the following:

    foreach (var item in project.GetPropertyValue<IEnumerable<string>>("projectCategories"))
    {
        <p>@item</p>
    }
    
  • Edgar Rasquin 326 posts 925 karma points
    Sep 26, 2017 @ 13:55
    Edgar Rasquin
    1

    Tobias,

    that did the trick! Thank you very much for your help!

  • Tobias Klika 101 posts 570 karma points c-trib
    Sep 26, 2017 @ 14:18
    Tobias Klika
    0

    No worries, glad I could help :)

Please Sign in or register to post replies

Write your reply to:

Draft