473,624 Members | 2,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(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!
Nov 18 '05 #1
1 2185
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
11280
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 = $this->_db->query($sql, DB_FETCHMODE_ASSOC); if (DB::isError($res)) { die($res->getMessage() . ' - ' .$res->getDebugInfo() . ' in: ' . __FILE__ . ' at line nr. ' . __LINE__); }
4
5256
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
13000
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 Refresh() between each test. This works: MyTreeView.Refresh(); .... but it causes a lot of flicker. The node text does not change. Only the TreeNode.ImageIndex changes.
0
1007
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 a TreeView. If I try to derive a class as follows public class MyTreeNode : TreeNode { }
0
3763
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 groups to answer my question, so I thought somebody might find this method useful. You can use the TreeNode.ValuePath to select a node using the TreeView.FindNode() method.
1
2446
by: Lukas Kurka | last post by:
Hi, Is there a way how to add Controls into TreeNode? Thank You Lukas
0
988
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.) occurs it returns an OLE DB Error. That's the only message I get. Is there any way I can get the real message error? I've heard something that changing a database server parameter force the database to return the correct error. My application...
4
3579
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 this an only this because it is a parent --childOfParent1 //cannot drag this, only the parent --childOfParent1 //can only drag parent -parent2 //yes, parent, can select and drag --childOfParent2 //no, cannot drag
2
1374
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 error". I goggled and knowing this one is related to Server space problem, and get one temporary solution that i restarted the Apache server after this my problem is solved. But i want to diagnose this problem why it would come and how i can solve...
0
8231
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8614
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8330
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8471
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7153
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5561
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4075
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1474
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.