472,353 Members | 1,723 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

How to add Child nodes under Parent nodes of TreeView in VB.NET from SqlServer database

This is my table

ID ChartName ParentLevel
1 Assets 0
2 Liabilities 0
3 Cash 1
4 Bank 1

I am able to retrieve Treeview Parent Node successfully using below code,

Dim Parent1 As TreeNode
Dim Child1 As TreeNode
Dim reader As SqlDataReader = cmd.ExecuteReader '(CommandBehavior.SingleRow)
While reader.Read()
If reader.Item("ParentLevel") = 0 Then
Parent1 = TreeView1.Nodes.Add(reader.Item("ChartName"))
End If
End While
End Try

but unable to populate child nodes under the related parent node.
Result in Treeview should be like this...


Help will be apricated.
Sep 29 '21 #1
0 5560

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

Similar topics

by: kaeli | last post by:
Can anyone explain this to me? It's driving me insane. Save this and run it in IE or Opera and then in Mozilla or Netscape 6+. In IE/Opera, I get...
by: pmcguire | last post by:
I have a treeview with a lot of nodes. I want to load only the nodes that are initially visible when the form loads, and then continue to populate...
by: Jack | last post by:
Hello, I am trying use a TreeView with checkboxes. I would like to check more than one node and allow all child nodes of selected nodes to be...
by: reandeau | last post by:
I'm building out a OO based app in PHP 5 but I'm getting a little confused on children contructing parents. I have a parent that looks like this:...
by: thanneman | last post by:
Hello all, First off all, I appollogize for my englisch. I have a problem. I have a table in my sql database with 2 fields. Field 1 is an ID,...
by: Daniel Rucareanu | last post by:
Hello, Does anybody knows how can you delete, in just one step, not using a loop, a subset of the child nodes of a given DOM parent node? The...
by: MA | last post by:
Hi, How to access the total number of child nodes from a parent node. For example, I would like to get the total number of child nodes from...
by: John Rogers | last post by:
This code only counts the parent nodes or rootnodes in a treeview, how do you count all the nodes in a treeview? // one way int NodeCounter = 0;...
by: arggg | last post by:
I am trying to add child nodes based on database query in which the users in the database are a part of the parent node. Here is my code. ...
by: basheed abdal | last post by:
In the below code was executed succesful but it doesn't added child and subnodes plse send me code how can i add child nodes and subchild nodes in...
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...

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.