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(Sende r As Object, E As EventArgs)
'Connection to the DB(DB connection objects)
Dim strConn As String =
"server=(local) ;database=North wind;integrated security=true;"
'Dim strConn As String =
"server=(local) ;database=pubs; trusted_connect ion=true;"
Dim objConn As New SqlConnection(s trConn)
'Created a Dataset to fill in the Data
Dim objDS As New DataSet
Dim daSuppliers As New SqlDataAdapter( "SELECT CompanyName,Sup plierID
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.Fil l(objDS, "dtSupplier s")
daProducts.Fill (objDS, "dtProducts ")
'daSuppliers.Fi ll(objDS)
'daProducts.Fil l(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("SuppToPro d", _
objDS.Tables("d tSuppliers").Co lumns("Supplier ID"), _
objDS.Tables("d tProducts").Col umns("SupplierI D"))
'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("d tSuppliers").Ro ws
nodeSupp = New TreeNode
nodeSupp.Text = rowSupp("Compan yName")
nodeSupp.ID = rowSupp("Suppli erID")
TreeView1.Nodes .Add(nodeSupp)
'Loop through SuppToProd which is a Datatable
For Each rowProd In rowSupp.GetChil dRows("SuppToPr od")
nodeProd = New TreeNode
nodeProd.Text = rowProd("Produc tName")
'nodeProd.Text = <a href ="">" &
rowProd("Produc tName") &"</a>
'<a href=""offers.a sp?catID=" & rsCat("ServID") &
""">" & rsCat("ServiceN ame") & "</a>
nodeProd.ID = rowProd("Produc tID")
nodeSupp.Nodes. Add(nodeProd)
Next
Next
'cleaned up to save server resources
objDS.Dispose()
daSuppliers.Dis pose()
daProducts.Disp ose()
objConn.Close()
objConn.Dispose ()
End sub
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!