在ASP.NET中的Treeview控件上 [英] On Treeview Control In ASP.NET

查看:106
本文介绍了在ASP.NET中的Treeview控件上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

- 1
     1.1
     1.2
   - 1.3
         1.3.1
         1.3.2
        - 1.3.3
            1.3.3.1
            1.3.3.2
+ 2
+ 3


大家好,

例如,如果我们认为上面提到的就像Treeview,这里共有5个父节点,它们是
1,
1.3,
1.3.3,
2,
3

对于像这样的父节点,

1
1.3
1.3.3

如果您在我的代码中观察到的话,我为每个循环写了3个.


Hi All,

For example if we consider that the above mentioned is like Treeview,Here total 5 parent nodes are there those are
1,
1.3,
1.3.3,
2,
3

For Parent Nodes Like,

1
1.3
1.3.3

I wrote 3 for each loop’s if you observe in my code.

protected void tvCategories_TreeNodeExpanded(object sender, TreeNodeEventArgs e)
    {
        try
        {
            foreach (TreeNode treenode in tvCategories.Nodes)
            {
                if (treenode.Text == e.Node.Text)
                {
                    treenode.Expand();
                    treenode.ImageUrl = "~/Images/OpenedBookColorInBlue.png";
                    break;
                }
                foreach (TreeNode t in treenode.ChildNodes)
                {
                    if (t.Text == e.Node.Text)
                    {
                        t.Expand();
                        t.ImageUrl = "~/Images/OpenedBookColorInBlue.png";
                        break;
                    }
                    foreach (TreeNode t1 in t.ChildNodes)
                    {
                        if (t1.Text == e.Node.Text)
                        {
                            t1.Expand();
                            t1.ImageUrl = "~/Images/OpenedBookColorInBlue.png";
                            break;
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.Write(ex.ToString());
        }
    }

protected void tvCategories_TreeNodeCollapsed(object sender, TreeNodeEventArgs e)
    {
        try
        {
            foreach (TreeNode treenode in tvCategories.Nodes)
            {
                if (treenode.Text == e.Node.Text)
                {
                    treenode.Collapse();
                    treenode.ImageUrl = "~/Images/ClosedBookColorInBlue.png";
                    break;
                }
                foreach (TreeNode t in treenode.ChildNodes)
                {
                    if (t.Text == e.Node.Text)
                    {
                        t.Collapse();
                        t.ImageUrl = "~/Images/ClosedBookColorInBlue.png";
                        break;
                    }
                    foreach (TreeNode t1 in t.ChildNodes)
                    {
                        if (t1.Text == e.Node.Text)
                        {
                            t1.Collapse();
                            t1.ImageUrl = "~/Images/ClosedBookColorInBlue.png";
                            break;
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.Write(ex.ToString());
        }
    }



现在以示例为例,如果我的Treeview如下所述,我想编写多少个forech循环?



Now For Example If my Treeview is like below mentioned,How many forech loops i want to write??

- 1

    1.1

    1.2

   - 1.3

           1.3.1

           1.3.2

         - 1.3.3

                1.3.3.1

                1.3.3.2

                - 1.3.3.3

                       1.3.3.3.1

                       1.3.3.3.2

                       - 1.3.3.3.3

                              1.3.3.3.3.1
+ 2

+ 3



根据我上面提到的树视图的代码,我想为每个循环的
写5 假设我有n个父节点,我该怎么办???
如果我那样增加我的代码,那将是不好的&;它得到了太多冗长的代码

所以这是不正确的naa.

那么解决方案是什么呢?

请给我...

在此先感谢,
VenkiDesai.k



According to my code for the above mention treeview I want to write 5 for each loop’s
Suppose If i have n-parent nodes what can i do????
If i increase my code like that it will be bad & it gets too much lenthy code

so it is not correct naa.

So what was the solution for this???

Please give me...

Thanks in Advance,
VenkiDesai.k

推荐答案

hi,

此链接将为您提供帮助.

将树视图加载到n个级别 [


this link will help you.

Loading a treeview to n levels[^]


这篇关于在ASP.NET中的Treeview控件上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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