Copied to clipboard

Flag this post as spam?

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


  • Jimmy Dan Mortensen 77 posts 197 karma points
    Jan 12, 2012 @ 10:45
    Jimmy Dan Mortensen
    0

    Order by not working i codebehind

    Hi Guys

    I've earlier gotten help to create this for-each sentence in the Codebehind of a usercontrol. The language is CS.

            dynamic afd = new umbraco.MacroEngines.DynamicNode(umbraco.NodeFactory.Node.GetCurrent());
            var Afdeling = afd.findAfdeling;
            var parent = afd.NodeById(afd.Afdelinger);
            System.Collections.Generic.List<string> afdnavne = new System.Collections.Generic.List<string>();

            if (parent != null)
            {
                foreach (var item in parent.Children.Where("Visible && " + Afdeling))
                {
                    afdnavne.Add(@item.firmanavn);
                };
            };

    On the "item"-document-type i have a property with the alias "firmaNavn", but if I add a .OrderBy("firmaNavn") then I get an error that the usercontrol cannot compile.

    Another option was to change it to order by NodeName, but changing it to:

    .OrderBy("Name")

    removes the error - but doesn't order it correctly. But if I put

    .OrderBy("Id")

    it orders the list in the order which i created the nodes :-) That will work for now, but sometime in the future it will give me a problem.

    What am I doing wrong?
    Jimmy Dan Mortensen

  • Gareth Evans 142 posts 334 karma points c-trib
    Jan 12, 2012 @ 22:55
    Gareth Evans
    0

    Hi, what version are you using?
    Please check with 4.7.1.1.
    I am pretty sure that nodeName (case sensitive) will work though.

  • Jimmy Dan Mortensen 77 posts 197 karma points
    Jan 19, 2012 @ 09:50
    Jimmy Dan Mortensen
    0

    Sorry for the late reply ... Things have been crazy

    I'm using this version: "umbraco v 4.7.1 (Assembly version: 1.0.4281.20201)"

    But nodeName is working so I'm happy :-)

     

Please Sign in or register to post replies

Write your reply to:

Draft