vuyiswamb 17 Posting Whiz

Good Day

I have posted this question before , i cant find it to continue from it. Let me start from Scratch because i did not find a Solution to this problem.

in my page am using a Treeview Control show like this

http://www.vuyiswamaseko.com/public/Wrong_Display.JPG

and am loading data in SQL like this

http://www.vuyiswamaseko.com/public/Query_Wrong_Display.JPG


and my code behind for loading the control looks like this

public void PopulateTreeFromCurr(int currID)
    {    
        // CurrStructDataSource calls sp_Traverse_Tree which returns an inordered list of nodes for a tree
        IEnumerable result = CurrStructDataSource.Select(DataSourceSelectArguments.Empty);
        // ID, Parent, Child, Description, Level, i
        int Parent, Child;
        CurriculumTreeView.Nodes.Clear();
        
        ArrayList CurrNodes = new ArrayList();

        if (result != null)
        {
            // an ordered set of nodes is given. parent always before current node except for root            
            foreach (System.Data.DataRowView row in result)
            {
                TreeNode newnode = new TreeNode(row["Description"].ToString(), row["NodeID"].ToString());
                CurrNodes.Add(newnode); // should setup a lookup between the id given by the ArrayList and that of the node
                // as we add the nodes, we can set up the hierarchy
                if (row["refParent"].ToString() == "")
                {   // don't have to add the root node to another node-it is the root
                }
                else
                {
                    Parent = Convert.ToInt32(row["refParent"]);
                    Child = Convert.ToInt32(row["ID"]);

                    TreeNode ParentNode = new TreeNode();
                    TreeNode ChildNode = new TreeNode();

                    ParentNode = (TreeNode)CurrNodes[Parent];
                    ChildNode = (TreeNode)CurrNodes[Child];
                    ParentNode.ChildNodes.Add(ChildNode);
                    CurrNodes[Parent] = ParentNode;
                }
            }
            if (CurrNodes.Count > 0)
            {
                // Add the first root compulsory which has all nodes attached to it
                CurriculumTreeView.Nodes.Add((TreeNode)CurrNodes[0]);
                CurriculumTreeView.ExpandAll();
            }
        }
    }

This above will show me results in this Manner in my application

http://www.vuyiswamaseko.com/public/Wrong_Display.JPG

but now i want the Display to be like this

http://www.vuyiswamaseko.com/public/Correct_Display.JPG

and i have changed my Query so that it gives me the Correct results from the SQL and i changed it to this

http://www.vuyiswamaseko.com/public/Query_Right_Display.JPG

and the above Results in SQl they are Correct , but now when i run it, in the Application i get an Error

http://www.vuyiswamaseko.com/public/Received_Error.JPG

Thanks