Home All Groups Group Topic Archive Search About
Author
11 Mar 2009 11:16 AM
mailmanny
I have a Tree View Which stores Values as well as name for each node. it is
populated from a database at runtime. In the page_load event i get the
database and build it to xml, then I use it as a datasource for my treevieew.
works great, except for one thing. I want to put a Special character into the
begining of the value string for any node that has a child node. i have the
code working but it dosn't acctually change the valueuntil the treeview is
clicked on. after the first postback to the server everything works. but on
the first display it dosn't contain the modifier.

Here's the code:
protected void TreeView1_DataBound(object sender, EventArgs e)
   {
            if (TreeView1.Nodes.Count > 0)
       {
           // Iterate through the root nodes in the Nodes property.
           for (int i = 0; i < TreeView1.Nodes.Count; i++)
           {
                    if (TreeView1.Nodes[i].ChildNodes.Count > 0)
               {
                    TreeView1.Nodes[i].Value = "$" + TreeView1.Nodes[i].
Value;
                    TreeView1.Nodes[i].SelectAction = TreeNodeSelectAction.
SelectExpand;
                   DisableParentNodes(TreeView1.Nodes[i]);
               }
            }
       }
   }

void DisableParentNodes(TreeNode node)
   {

       for (int i = 0; i < node.ChildNodes.Count; i++)
       {

           if (node.ChildNodes[i].ChildNodes.Count > 0)
           {
               node.ChildNodes[i].Value = "$" + node.ChildNodes[i].Value;
               node.ChildNodes[i].SelectAction = TreeNodeSelectAction.
SelectExpand;
               DisableParentNodes(node.ChildNodes[i]);
           }
       }
   }
See the Test Site at www.bettencourtfurniture.com/aspsite/itemstest.aspx

--
Message posted via http://www.dotnetmonster.com