Copied to clipboard

Flag this post as spam?

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


  • Anumod 16 posts 126 karma points
    Jun 17, 2019 @ 15:08
    Anumod
    0

    How can i find a child node by comparing a string value with its on umbraco field?

  • Rhys Hamilton 140 posts 942 karma points
    Jun 17, 2019 @ 15:27
    Rhys Hamilton
    100

    To retrieve a list of child nodes by one of their properties which matches a string value, you could use something like the following:

    @{
        var stringValue = "YourStringValue"; 
    
        var childNodes = Model.Content.Children.Where(x => x.GetPropertyValue<string>("yourProperty") == stringValue);
    
        if (childNodes != null)
        {
            // Iterate through childNodes
            foreach (var item in childNodes)
            {
                // Apply your logic here
            }
        }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft