asp tutorials, asp.net tutorials, sample code, and Microsoft news from 15Seconds
Data Access  |   Troubleshooting  |   Security  |   Performance  |   ADSI  |   Upload  |   Email  |   Control Building  |   Component Building  |   Forms  |   XML  |   Web Services  |   ASP.NET  |   .NET Features  |   .NET 2.0  |   App Development  |   App Architecture  |   IIS  |   Wireless
 
Pioneering Active Server
 Power Search





Active News
15 Seconds Weekly Newsletter
• Complete Coverage
• Site Updates
• Upcoming Features

More Free Newsletters
Reference
News
Articles
Code Samples
Components
Tools
New
Free
Downloads
Vendors
FAQ
Feedback
Books
Links
DL Archives
Community
Messageboard
List Servers
Mailing List
WebHosts
Consultants
Tech Jobs
15 Seconds
Home
Site Map
Press
Legal
Privacy Policy
internet.commerce














internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

HardwareCentral
Compare products, prices, and stores at Hardware Central!

Here is some code I used to fill in a treeview control. I determined child/parent relationships by a returned field from the database.

Here are some sample recordsets. The TreeNodes table is the same structure.
CategoryID CategoryName CategoryTO
ASD.AMAS Category Title ASD
ASD.AMAS.NS Category Title 1.1 ASD.AMAS
ASD.AMAS.NS.AS Category Title 1.1.1 ASD.AMAS.NS
ASD.AMAS.NS.AUCCategory Title 1.1.1 ASD.AMAS.NS
ASD.AMAS.TDA Category Title 1.2 ASD.AMAS
ASD.AMAS.TDA.TACategory Title 1.2.1 ASD.AMAS.TDA
ASD.AMAS.TDA.TDCategory Title 1.2.2 ASD.AMAS.TDA
ASD.APS Category Title 2 ASD
ASD.APS.C Category Title 2.1 ASD.APS
ASD.APS.DM Category Title 2.2 ASD.APS
ASD.APS.DM.A10 Category Title 2.2.1 ASD.APS.DM
ASD.APS.DM.C2 Category Title 2.2.2 ASD.APS.DM
ASD.APS.DM.E2C Category Title 2.2.3 ASD.APS.DM

The Code


Set Conn = Server.CreateObject("ADODB.Connection")

Conn.Open "DSN=MyDB"
set RS = Conn.execute("{call qryTreeNodesAll}")

if RS.EOF then
	response.write "TreeView1.Nodes.Add ,,,""No Records"""
else
	do while NOT RS.EOF
		s = RS(2)

		count = 0
		pos = 1
		lookfor = "."
		Do While True
			pos = InStr(pos, s, lookfor)
        
			If pos > 0 Then
				count = count + 1
				pos = pos + 1
			Else
				Exit Do
			End If
		Loop

		select case count
			case 0
				response.write "TreeView1.Nodes.Add ,,"""&RS(0)&""","""&RS(1)&"""" & vbCrLf
			case else
				response.write "TreeView1.Nodes.Add """&RS(2)&""",4,"""&RS(0)&""","""&RS(1)&"""" & vbCrLf
		end select

		RS.Movenext
	loop
end if





email this code sample to a colleague

Related Articles
Jan 24, 1997 - Simple ASP Chat
This 15 Seconds' issue contains source code and step by step instructions for creating a chat session using Active Server pages, HTML and a standard web browser. Also demonstrated is writing and reading of a file with an Active Server page.
[Read This Article]  [Top]
Apr 6, 1997 - Creating a List Server with ASP
This issue describes how to make a list server using Active Server, SQL Server, and Stephen Genusa's ASPMail Component. Included are source and instructions for adding the user to the list from a Active Server page, removing the user from the list via a Active Server page, and sending mail to the whole list.
[Read This Article]  [Top]
Apr 22, 1997 - Active Server Components with VS 5.0
A rewrite of part one of a four-part series on Active Server objects. A simple example of creating a Active Server Component in Visual Studio 5.0 using the Active Template Library 2.0. The example component retrieves the user's cookie, if not available issues a new 128-bit cookie. Included in the issue is the source code and step by step instructions. This issue has been rewritten to illustrate the use of Visual Studio 5.0 and ATL 2.0 in writing Active Server Components.
[Read This Article]  [Top]
Jul 31, 1997 - Creating a Category Site with ASP
In this issue 15 Seconds implements a catalog site that is build with Active Server pages and SQL Server. Along with the implementation there is source code and a discussion of the advantages and disadvantages of creating a catalog site that gets its content from a database. Included are pages for displaying products, creating a menu page, category page, and running a search across a database.
[Read This Article]  [Top]
Sep 11, 1997 - The Last-Modified Header in ASP
A complete discussion of the Last Modified header and the Expires header including the effect they have on Active Server page and various browsers.
[Read This Article]  [Top]
Related Books
Working with Active Server Pages
Related Knowledge Base Articles
HOWTO: Disabling Cookies Sent by Active Server ...
Q163010 - 1997.06.23
IIS Execution File Text Can Be Viewed in Client
Q164059 - 1997.06.23
INF: How to Access SQL Server Within Active Ser...
Q169377 - 1997.06.23
How To Use Response.Redirect in a Server Script
Q159402 - 1997.06.23
How To Stop Users from Displaying a Frame Outsi...
Q159977 - 1997.06.23



Support the Active Server Industry

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs