Click here to Skip to main content
12,763,515 members (32,595 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ASP.NET
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...


code is

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 14-Dec-12 19:27pm
Updated 14-Dec-12 19:56pm
Krunal Rohit 15-Dec-12 0:45am
Elaborate your question... Provide your code...
-Krunal R.
Member 9644686 15-Dec-12 0:53am
i sended...
Krunal Rohit 15-Dec-12 0:56am
Its sent, not sended...
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

to bind data go through this article

Data Binding TreeView in C#[^]

and to clear

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
Web02 | 2.8.170217.1 | Last Updated 15 Dec 2012
Copyright © CodeProject, 1999-2017
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