By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,734 Members | 855 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,734 IT Pros & Developers. It's quick & easy.

populating treeview menu from db(treenode not defined error)

P: n/a
Hi Guys,
I have an application below that is treeview menu populated from the
database which works with 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")


'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
objDS.Relations.Add("SuppToProd", _
objDS.Tables("dtSuppliers").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")


'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")




'cleaned up to save server resources





End sub
*** Sent via Developersdex ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Hi Guys,
Now its ok just didn't add the appropriate
TreeView1 Control whch was needed in VS.Net.
*** Sent via Developersdex ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.