473,748 Members | 2,294 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 1381

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

Similar topics

0
1252
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
2090
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
2683
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
1667
by: tzvikaz | last post by:
Let's say I have this db: Table: Companies ------- Ford Toyota BMW Table: CarTypes --------
1
2194
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
1298
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
2296
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
3189
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
8377
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
8983
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9528
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...
0
9359
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9310
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,...
1
6792
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
4592
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
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.