Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi brothers and sisters i am beginner in this field so please help me i am already binded the database to the tree view but i Want to clear the tree view and bind the same database another once how can i do please help me
i use this but it doesn't work...

TreeView1.Attributes.Clear();


code is

C#
public void loadtreeview(string connection)
        {
            FirstMiniProject.FirstMiniProject f = new FirstMiniProject.FirstMiniProject(connection);
            string sql = string.Format("SELECT name FROM sys.databases WHERE name NOT IN ('master', 'tempdb', 'model', 'msdb')");
            DataTable tab = new DataTable();
            tab = f.loadtable(sql);
            for (int i = 0; i < tab.Rows.Count; i++)
            {
                string root = tab.Rows[i]["name"].ToString();
                TreeView1.Nodes.Add(new TreeNode(root));
                string sql1 = string.Format("USE {0} SELECT name FROM sys.Tables", root);
                DataTable tab1 = new DataTable();
                tab1 = f.loadtable(sql1);
                for (int j = 0; j < tab1.Rows.Count; j++)
                {
                    string child = tab1.Rows[j]["name"].ToString();
                    TreeView1.Nodes[i].ChildNodes.Add(new TreeNode(child));
                }

            }
        }

i want to clear the tree view after that i will call this function once again to bind;;;;
Posted
Updated 14-Dec-12 18:56pm
v3
Comments
[no name] 15-Dec-12 0:45am    
Elaborate your question... Provide your code...
-Krunal R.
Member 9644686 15-Dec-12 0:53am    
i sended...
[no name] 15-Dec-12 0:56am    
Its sent, not sended...

to bind data go through this article

Data Binding TreeView in C#[^]

and to clear
C#
TreeView1.Nodes.Clear()
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900