Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
| Search | Today's Posts | Mark Forums Read
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 28th, 2006, 08:31 AM
Registered User
Join Date: Apr 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with Treeview


I have a table which has 3 columns. This is how my table looks with the data


now i want to display this data in a treeview control. I used the code example but it dint help me.I hope somebody can help me. Please its urgent.

i want the treeview to be displayed like this:

|-tester(this is a child of test)

This is what i tried

Dim strConn As String = "server=.;database=Northwind;integrated security=true;"

Dim objConn As New SqlConnection(strConn)

Dim objDS As New DataSet

Dim daSuppliers As New SqlDataAdapter("SELECT * FROM tree where parent=0", objConn)

Dim daProducts As New SqlDataAdapter("SELECT * FROM tree where parent=id", objConn)

daSuppliers.Fill(objDS, "dtSuppliers")

daProducts.Fill(objDS, "dtProducts")


objDS.Relations.Add("SuppToProd", _

    objDS.Tables("dtSuppliers").Columns("id"), _


Dim nodeSupp, nodeProd As TreeNode

Dim rowSupp, rowProd As DataRow

For Each rowSupp In objDS.Tables("dtSuppliers").Rows

    nodeSupp = New TreeNode

    nodeSupp.Text = rowSupp("name")

    nodeSupp.ID = rowSupp("id")


    For Each rowProd In rowSupp.GetChildRows("SuppToProd")

        nodeProd = New TreeNode

        nodeProd.Text = rowProd("name")

        nodeProd.ID = rowProd("id")




  'clean up






Can somebody please help with or guide me as to where or what i am doing wrong or what i am missing.

Thanks in advance.

Old May 17th, 2006, 06:26 AM
Registered User
Join Date: May 2006
Location: CHENNAI, TAMIL NADU, India.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to SYEDHANIF Send a message via Yahoo to SYEDHANIF


amor 1998

apply collection object to get the parent node


Code Samples

dim ParentList as new ArrayList()

do same this for other node

then apply the for next loop statement
 for that parentnode
it will work

still doubt pls contact


Similar Threads
Thread Thread Starter Forum Replies Last Post
treeview problem while migrate from 1.1 to 2.0 in nittin14 ASP.NET 2.0 Basics 2 September 8th, 2008 09:23 AM
Treeview collapse problem 2 syedwaqarali ASP.NET 2.0 Professional 0 July 13th, 2007 04:26 AM
TreeView Problem Medes C# 2005 0 April 23rd, 2006 07:20 AM
TreeView Problem Aaron Edwards ASP.NET 1.0 and 1.1 Basics 0 December 20th, 2005 04:19 AM
Treeview Webcontrol problem Victor ADO.NET 2 September 9th, 2004 10:55 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.