473,498 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TreeView Populated from DB (Error in V.Studio.Net)

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)
'Connection to the DB(DB connection objects)
Dim strConn As String =
"server=(local);database=Northwind;integrated security=true;"
'Dim strConn As String =
"server=(local);database=pubs;trusted_connection=t rue;"

Dim objConn As New SqlConnection(strConn)

'Created a Dataset to fill in the Data
Dim objDS As New DataSet

Dim daSuppliers As New SqlDataAdapter("SELECT CompanyName,SupplierID
FROM Suppliers", objConn)
Dim daProducts As New SqlDataAdapter("SELECT ProductName, ProductID,
SupplierID FROM Products", objConn)

'Filled in the Data and close connections
'daSuppliers is the DataAdapter
daSuppliers.Fill(objDS, "dtSuppliers")
daProducts.Fill(objDS, "dtProducts")

'daSuppliers.Fill(objDS)
'daProducts.Fill(objDS)
objConn.Close()

'A relation is created here because the Dataset has more than one
Datatable (there must be a common field in both
' to define the Parent Child relationship. In this is the SupplierID
objDS.Relations.Add("SuppToProd", _
objDS.Tables("dtSuppliers").Columns("SupplierID"), _
objDS.Tables("dtProducts").Columns("SupplierID"))
'Created TreeView datatypes
Dim nodeSupp, nodeProd As TreeNode
Dim rowSupp, rowProd As DataRow
'Loop through the datasets and populate the TreeView
For Each rowSupp In objDS.Tables("dtSuppliers").Rows

nodeSupp = New TreeNode

nodeSupp.Text = rowSupp("CompanyName")

nodeSupp.ID = rowSupp("SupplierID")

TreeView1.Nodes.Add(nodeSupp)

'Loop through SuppToProd which is a Datatable
For Each rowProd In rowSupp.GetChildRows("SuppToProd")

nodeProd = New TreeNode

nodeProd.Text = rowProd("ProductName")

'nodeProd.Text = <a href ="">" & rowProd("ProductName")
&"</a>
'<a href=""offers.asp?catID=" & rsCat("ServID") & """>" &
rsCat("ServiceName") & "</a>

nodeProd.ID = rowProd("ProductID")

nodeSupp.Nodes.Add(nodeProd)

Next

Next

'cleaned up to save server resources

objDS.Dispose()

daSuppliers.Dispose()

daProducts.Dispose()

objConn.Close()

objConn.Dispose()
End sub
Nov 18 '05 #1
0 1183

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

42
11469
by: lauren quantrell | last post by:
So many postings on not to use the treeview control, but nothing recently. Is it safe to swim there yet with Access 2000-Access 2003?
3
12155
by: Ian | last post by:
Hi, I've been trying to create a listview and treeview with icons. You would think it's a pretty straight forward task. API documentation states you simply assign an ImageList - that's been...
4
1360
by: Danny | last post by:
I have installed Internet Web Controls locally in my machine, and in our server. I also added them into the toolbox tab in my Visual Interdev and on design layout, I can see the treeview object...
1
2174
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...
2
3842
by: Dave Wurtz | last post by:
All, I have a treeview on my form that has a lot of nodes on it. I would like to populate this treeview on another thread so my form will still paint while it is being populated. I have...
3
3089
by: edamron | last post by:
I am writing my first VB.Net program and have come across an interesting problem. My department generates large volumes of documents. By law we are required to keep the documents for a specific...
3
2235
by: Shawn | last post by:
Hi. I'm working with the TreeView control in my ASP.NET 1.1 application. I have a problem I haven't been able to figure out. When I click on a node (not expand), whether it's a parent node, a...
0
1286
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...
1
4897
by: doemon | last post by:
Hi, I'm working on a pagination control and I need to dynamically rerender a treeview to display the next set of nodes depending on which page we're on. For example, page 1 will dispaly only...
0
7125
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
7004
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...
0
7167
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,...
0
7208
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
7379
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...
0
5464
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,...
0
3095
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...
1
657
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
292
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...

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.