Copied to clipboard

Flag this post as spam?

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


  • trfletch 598 posts 604 karma points
    Feb 18, 2011 @ 00:25
    trfletch
    0

    Sorting custom section nodes alphabetically

    Hi,

    Me again, I have an Umbraco 4.5.2 website and I am creating a custom section as per the video tutorials. I have got the nodes from my table displaying correctly but I would like to sort them alphabetically by Organisation. Can someone please let me know how I can do that, I am very new to asp.net so I apologise if this is a really simple question. The code I have so far is:

    namespace

     

     

    Portal.Ads

    {

     

     

    public class loadAdsTree:BaseTree

    {

     

     

    public loadAdsTree(string application) :

     

     

    base(application) { }

     

     

    protected override void CreateRootNode(ref XmlTreeNode rootNode)

    {

    rootNode.Icon = FolderIcon;

    rootNode.OpenIcon = FolderIconOpen;

    rootNode.NodeType =

     

    "init" + TreeAlias;

    rootNode.NodeID =

     

    "init";

    }

     

     

    public override void Render(ref XmlTree Tree)

    {

     

     

    IRecordsReader reader = Application.SqlHelper.ExecuteReader("select * from Users where activeStatusID = '1'");

     

     

    while (reader.Read())

    {

     

     

    XmlTreeNode xNode = XmlTreeNode.Create(this);

    xNode.NodeID = reader.GetInt(

     

    "id").ToString();

    xNode.Text = reader.GetString(

     

    "Organisation");

    xNode.Icon =

     

    "folder.gif";

    xNode.Action =

     

    "javascript:openAdvertisers(" + reader.GetInt("id").ToString() +")";

    Tree.Add(xNode);

    }

    }

     

     

    public override void RenderJS(ref System.Text.StringBuilder Javascript)

    {

    Javascript.Append(

     

    @"

    function openAdvertisers(id)

    {

    parent.right.document.location.href = 'plugins/editAdvertisers.aspx?id=' + id;

    }

    "

     

     

    );

     

     

    }

     

    }

    }

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Feb 18, 2011 @ 09:24
    Dirk De Grave
    0

    Change your sql statement to include the sorting clause?

    For example:

    select * from Users where activeStatusID = '1' order by organization asc

     

    Cheers,

    /Dirk

  • 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