473,387 Members | 1,779 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,387 software developers and data experts.

populating treeview menu from db(treenode not defined error)

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
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
1 2170
Hi Guys,
Now its ok just didn't add the appropriate
TreeView1 Control whch was needed in VS.Net.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2

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

Similar topics

7
by: Toni | last post by:
The following code: $sql = 'SELECT user_id FROM ' . TC_DATA_NEW_TABLE_NAME . 'subscribe WHERE ' . TC_UTIL::parentClause($this->getType(), TC_DATA_NEW_TABLE_PREFIX . '_type'); $res =...
4
by: Jeroen Ceuppens | last post by:
Hi, I want to make something that adds a TreeNode to the end of TreeView, that TreeView Looks like + Level 1 + Level 2 + Level 3 - Level last
2
by: Mark Jerde | last post by:
VS .NET 2003, Googling, msdn searching not successful. I'm using the images of nodes of a TreeView to show the Pass/Fail results of several tests. The tests are a little slow so I would like to...
0
by: David | last post by:
Hi, I've been working with TreeView for ASP.NET. I've had several puzzling difficulties with it. For example I can write an application that works fine programmatically adding TreeNode objects to...
0
by: Jared | last post by:
I am using a TreeView with data stored in a database and have been trying to store a node index over a postback and re-select the node without using javascript. I couldn't find anything in these...
1
by: Lukas Kurka | last post by:
Hi, Is there a way how to add Controls into TreeNode? Thank You Lukas
0
by: giovanibettiol | last post by:
Hello, I have a Delphi application using DBExpress do access a MS SQL Server 2005 database. The problem is that everytime a database error (primary key violated, field cannot be null, etc.)...
4
by: jmDesktop | last post by:
I have searched everywhere and tried several things. I have a treeview with and want to be able to only select a parent node. For example: root //don't want to drag this -parent1 //yes, drag...
2
by: maheswaran | last post by:
Hi all, I installed xampp in windows server 2003. I hosted my application (Docman) into xampp. when i list the documents from table i got the "Failed to retrieve documents: DB Error: unknown...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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...

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.