Click here to Skip to main content
15,891,708 members
Articles / Web Development / ASP.NET

Dynamically Populating a Microsoft Internet Explorer TreeView Web Control from a Database using SQL Server 2000 & XML Explicit

Rate me:
Please Sign up or sign in to vote.
4.68/5 (32 votes)
20 May 2003CPOL5 min read 264.1K   2K   85  
How to build an Internet Exporer TreeView Web Controls node list dynamically using SQLXML and the Explicit mode
create procedure spReflexiveNodesText
	as
select
	1 as Tag,
	0 as Parent,
	null as [TREENODES!1!text],
	null as [treenode!2!text],
	null as [treenode!2!NavigateUrl],
	null as [treenode!3!text],
	null as [treenode!3!NavigateUrl],
	null as [treenode!4!text],
	null as [treenode!4!NavigateUrl]
union 
	all
select
	2 as Tag,
	1 as Parent,
	null,
	fldDiagnosisLabel as [treenode!2!text],
	'Javascript:FillBox("' + cast(fldDiagnosisId as varchar(10)) + '")'
		 as [treenode!2!NavigateUrl],
	null as [treenode!3!text],
	null as [treenode!3!NavigateUrl],
	null as [treenode!4!text],
	null as [treenode!4!NavigateUrl]
from
	tblDiagnosis
where
	fldTierNumber = 1
union
	all
select
	3 as Tag,
	2 as Parent,
	null,
	t1.fldDiagnosisLabel,
	'Javascript:FillBox("' + cast(t1.fldDiagnosisId as varchar(10)) + '")',
	t2.fldDiagnosisLabel as [treenode!3!text],
	'Javascript:FillBox("' + cast(t2.fldDiagnosisId as varchar(10)) + '")'
	as [treenode!3!NavigateUrl],
	null,
	null
from
	tblDiagnosis as t1
inner join
	tblDiagnosis as t2
on
	t1.fldDiagnosisId = t2.fldDiagnosisParentId
where
	t1.fldTierNumber = 1
and
	t2.fldTierNumber = 2
union
	all
select
	4 as Tag,
	3 as Parent,
	null,
	t1.fldDiagnosisLabel,
	'Javascript:FillBox("' + cast(t1.fldDiagnosisId as varchar(10)) + '")',
	t2.fldDiagnosisLabel,
	'Javascript:FillBox("' + cast(t2.fldDiagnosisId as varchar(10)) + '")',
	t3.fldDiagnosisLabel as [treenode!4!text],
	'Javascript:FillBox("' + cast(t3.fldDiagnosisId as varchar(10)) + '")'
		 as [treenode!4!NavigateUrl]
from
	tblDiagnosis as t1
inner join
	tblDiagnosis as t2
on
	t1.fldDiagnosisId = t2.fldDiagnosisParentId
inner join
	tblDiagnosis as t3
on
	t2.fldDiagnosisId = t3.fldDiagnosisParentId
where
	t1.fldTierNumber = 1
and
	t2.fldTierNumber = 2
and
	t3.fldTierNumber = 3
order by
	[TREENODES!1!text],
	[treenode!2!text],
	[treenode!3!text],
	[treenode!4!text]
for 
	xml explicit

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer
Australia Australia
Simon Segal resides in Melbourne Australia, is a certified MCAD, MCSD, MCDBA, MCSE, MCST BizTalk Specialist and has been working in the Software Development industry for some 10 years now. His key area of interest are distributed systems / SOA built with Microsoft technologies.

Comments and Discussions