473,394 Members | 1,845 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Populating TreeView from DataBase

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(sqlDataReader["LevelName"].ToString(), sqlDataReader["ID"].ToString());

if (tvMain.FindNode(sqlDataReader["ParentLevel"].ToString()) == null)
{
tvMain.Nodes.Add(treeNode);

}
else
{
parentNode = tvMain.FindNode(sqlDataReader["ParentLevel"].ToString());
parentNode.ChildNodes.Add(treeNode);
}
}


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

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

Similar topics

0
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...
0
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...
2
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...
2
by: tzvikaz | last post by:
Let's say I have this db: Table: Companies ------- Ford Toyota BMW Table: CarTypes --------
1
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...
0
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...
0
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...
2
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...
3
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
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...

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.