Copied to clipboard

Flag this post as spam?

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


  • David Amri 214 posts 740 karma points
    Nov 17, 2020 @ 08:09
    David Amri
    0

    Not getting values from checkbox list

    Hi,

    I'm confused why I'm not able to get the values from a checkbox list property. I'm getting this error like there's no data.

    object reference not set to an instance of an object
    

    So the code looks like this:

    var rootPage = Umbraco.TypedContentAtRoot().FirstOrDefault(x => x.ContentType.Alias.Equals("kund_unikum_master_d"));
    
    var test = rootPage.Descendants().Where(x => x.HasProperty("areaOfInterest")).FirstOrDefault();
    
    @foreach (var item in test.GetPropertyValue<IEnumerable<string>>("areaOfInterest"))
    {
        <span>@item</span>
    }
    

    I'm correctly getting the first node with the property present with:

    <div>@test.Name</div>
    
  • Markus Johansson 1945 posts 5899 karma points MVP 2x c-trib
    Nov 17, 2020 @ 21:23
    Markus Johansson
    0

    Hi!

    Do you have a stack trace for the error?

    What if you do

  • 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