Click here to Skip to main content
12,065,888 members (27,057 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET Javascript
Hi all,

I have a tree view with parent and child nodes. If i click on a nodes, I want the description about that node in a textbox. this should happen for all the nodes. how should I do this.

My code behind I have tried is:
private void fetchtreeview()
       {
           TVContent.Nodes.Clear();
           DataTable topics = dsSOW.Tables["Tableofcontents$"];
           drText = dsSOW.Tables["Tableofcontents" + "$"].Select("Mappingcode is NULL");
           if (drText.Length > 0)
           {
               foreach (DataRow drItem in drText)
               {
                   string ss = drItem.ItemArray[1].ToString();
 
                   string ss1 = drItem.ItemArray[0].ToString();
                   if (ss1 != string.Empty)
                   {
                       TreeNode node = new TreeNode(ss, ss1);
                       //txtArea.Text = node.Text;
                       node.PopulateOnDemand = false;
                       TVContent.Nodes.Add(node);
 
                       PopulateNode(node);
                   }
               }
           }
       }
       protected void PopulateNode(TreeNode node1)
       {
           decimal order = Convert.ToDecimal(node1.Value);
           drText = dsSOW.Tables["Tableofcontents" + "$"].Select("Mappingcode='" + order + "'");
            if (drText.Length > 0)
           {
               foreach (DataRow drItem in drText)
                {
                   string ss = drItem.ItemArray[1].ToString();
                   string ss1 = drItem.ItemArray[0].ToString();
                   //decimal order1 = Convert.ToDecimal(ss1.ToString());
                   TreeNode node = new TreeNode(ss, ss1);
                   DataRow[] drText1 = dsSOW.Tables["Content" + "$"].Select("contentcode='" + ss1 + "'");
                   if (drText1.Length > 0)
                   {
                      foreach (DataRow drItem1 in drText1)
                       {
                           txtArea.Text = txtArea.Text + drItem1.ItemArray[1].ToString();
                       }
                   }
                   node1.ChildNodes.Add(node);
                   snode = node.Value;
                   if (snode != string.Empty)
                   {
                       drText = dsSOW.Tables["Tableofcontents$"].Select("Mappingcode='" + snode + "'");
                       if (drText.Length > 0)
                       {
                           PopulateNode(node);
                       }
                   }
               }
             }
           TVContent.Attributes.Add("OnClick", "OnTreeClick(event)");
           //TVContent.Attributes.Add("onmouseover", "showToolTip(event)");
            }

On implementing this code, I am getting the descriptions about the nodes in page load itself.. I want that to appear only after i click the nodes. And i fetch values for description from a dataset.

Please Help.!
Thanku.!
Posted 14-Oct-12 21:31pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

hi

check out the following links
link1[^]
link2[^]
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

u can try selectindxchanged event for tree nodes
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web03 | 2.8.160207.1 | Last Updated 16 Oct 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100