在单击树节点值时在文本框中显示内容 [英] display contents on a textbox on clicking tree node value

查看:91
本文介绍了在单击树节点值时在文本框中显示内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个带有父级和子级节点的树形视图.如果单击某个节点,则需要在文本框中提供有关该节点的描述.这应该在所有节点上发生.我应该怎么做.

我尝试过的代码如下:

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.!

推荐答案

]; drText = dsSOW.Tables ["Tableofcontents" +"
"]; drText = dsSOW.Tables["Tableofcontents" + "


"].Select(映射代码为NULL"); 如果(drText.Length> 0) { foreach(drText中的DataRow drItem) { 字符串ss = drItem.ItemArray [1] .ToString(); 字符串ss1 = drItem.ItemArray [0] .ToString(); 如果(ss1!= string.Empty) { TreeNode节点=新的TreeNode(ss,ss1); //txtArea.Text = node.Text; node.PopulateOnDemand = false; TVContent.Nodes.Add(node); PopulateNode(node); } } } } 受保护的void PopulateNode(TreeNode node1) { 十进制顺序= Convert.ToDecimal(node1.Value); 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 =""+顺序+""); 如果(drText.Length> 0) { foreach(drText中的DataRow drItem) { 字符串ss = drItem.ItemArray [1] .ToString(); 字符串ss1 = drItem.ItemArray [0] .ToString(); //十进制order1 = Convert.ToDecimal(ss1.ToString()); TreeNode节点=新的TreeNode(ss,ss1); DataRow [] drText1 = dsSOW.Tables ["Content" +"
"].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" + "


这篇关于在单击树节点值时在文本框中显示内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆