473,698 Members | 2,737 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Populating TreeView from DataBase

1 New Member
hi

I have table with following structure and data

ID | LevelName | LevelNumber | ParentLevel
100 | AAA | 1 | 0
101 | BBB | 2 | 100
102 | CCC | 2 | 100
103 | DDD | 1 | 0
105 | EEE | 2 | 103
106 | FFF | 3 | 102
107 | GGG | 3 | 102
108 | HHH | 3 | 102


From this table i want to generate a treeview with the following structure

AAA
- BBB
- CCC
--- FFF
--- GGG
--- HHH
DDD
- EEE


For this i am using the following code


while (sqlDataReader. Read())
{
treeNode = new TreeNode(sqlDat aReader["LevelName"].ToString(), sqlDataReader["ID"].ToString());

if (tvMain.FindNod e(sqlDataReader["ParentLeve l"].ToString()) == null)
{
tvMain.Nodes.Ad d(treeNode);

}
else
{
parentNode = tvMain.FindNode (sqlDataReader["ParentLeve l"].ToString());
parentNode.Chil dNodes.Add(tree Node);
}
}


But this code dosnt work properly. Could anyone help me on this issue
May 22 '07 #1
0 1378

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1250
by: serge calderara | last post by:
Dear all, I have an VB windows application that colect information form a remote database and then populate the tree view with part of the reords. As database data can be huge , I have used the Queeue threading process to colect those information. Then when the callback function is called I populate my treeview with teh return object. As the treeview control is not on the same thread, I have to use the Invoke method.
0
2088
by: imassadpk | last post by:
Hi all, Apprecite your help in resolving this tricky issue... I am trying implementing Recurrsive TreeView in MS. Access 2003 ADP project. So far, no luck :( The Problem: This sample snippet is all written for DAO and doesn't work in ADO
2
2681
by: Janus | last post by:
Hello. I need a little advice for populating the treeview control. I dont want my application to hang while populating the treeview, there is a lot of data what's the best approach? Maybe something eventbased but how? please help... Should I avoid populating the treeview control using a thread?
2
1664
by: tzvikaz | last post by:
Let's say I have this db: Table: Companies ------- Ford Toyota BMW Table: CarTypes --------
1
2188
by: naijacoder naijacoder | last post by:
Hi Guys, I have an application below that is treeview menu populated from the database which works with asp.net webmatrix.But when i put it into code behind in Visual Studio.Net it gives the errors "TreeNode Not defined" "name TreeeView1 not defined" Can anybody tell me what 'm doing wrong? Sub Page_load(Sender As Object, E As EventArgs)
0
1295
by: Erland | last post by:
Hello all, I have just installed visual studio .net 2005 and started developing programs in asp.net 2.0. I have a scenerio where I have to populate treeview child nodes based on the entries being entered in textbox,but there is this thing I need to consider. Values in treeview nodes should be populated as nodes, all child nodes in this case, as soon as vales are being entered in textbox. That is to say, if I enter H in textbox then H...
0
2290
by: drop | last post by:
Hi, I'm currently working with the Treeview control in ASP .Net 2.0. The tree is filled dynamically based on data contained in a MySQL Database. Here is the exact behavior I want : 1 - User clicks on a node to expand it. 2 - Add a child node to the node clicked by the user saying the tree is loading that part. So here, I also need to expand the node clicked by
2
3183
by: Steve Arndt | last post by:
I'm trying to populate a vb.net treeview using a SQLDataReader at Treeview1_BeforeExpand. Basically I have a Treeview with 5 parent nodes and 1 dummy child node per parent. The first parent node is called Address is the parent I'm trying to add new children under. When BeforeExpand is triggered, it removes the dummy child under the Adress parent node based on e.Node.FirstNode.Remove. Then runs a private sub called PopulateNode with...
3
8374
by: babu17 | last post by:
hi , I have a database table with 3 columns table1: eid ename parentid 0 root 0 1 child1 0 2 child2 0
0
1472
by: hardieca | last post by:
Hi, I have created a treeview bound to a sitemap provider. I have put it into a user control (the control will be used for similar, but not always identical, functionality). The treeview expresses the hierarchy of sections in my website. In a page that edits sections, I would like to use the treeview to allow the user to select a parent section. My treeview is accurately showing my section tree, but of course when I click a link I am...
0
8610
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7740
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.