Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello All ,

I have Store procedure which create the hierarchy of the user.Next step is that i need to bind result set with tree view control.I am getting difficulty in showing the value.Can any body help me in this.
here is sample SP

SQL
DECLARE @sys_user TABLE 
	(UserId bigint
	,FRST_NM varchar(100)
	,LST_NM varchar(100)
	,APROV_ID bigint)
	
Insert into @sys_user
Select 800000000, 'Dave', 'Smith', NULL
UNION Select 810000000, 'Michael', 'Chak',800000000
UNION Select 811000000, 'David', 'Boon',810000000
UNION Select 811100000, 'Glen','Macgrath',811000000
UNION Select 811110000, 'Alex', 'Boon',811100000
UNION Select 811111000, 'Jim', 'Foley',811111000
UNION Select 821000000,'Stephan', '',800000000

DECLARE  @UserId BIGINT=800000000

select * from @sys_user

;With submenu (UserId,Name,APROV_ID,lvl)
AS
(
	Select UserId, FRST_NM + ' '+LST_NM as Name,APROV_ID, 0 lvl
	From @sys_user
	Where UserId=@UserId
	Union ALL Select
		su.UserId
		,su.FRST_NM + ' '+su.LST_NM
		,su.APROV_ID
		,sm.lvl+1
	From @sys_user su
		Join submenu sm ON su.APROV_ID=sm.UserId
)
Select SPACE(lvl*2)+STR(UserID) + '||  '+Name,lvl
From submenu
Order by UserId
Posted
Comments
fjdiewornncalwe 26-Sep-12 12:21pm    
Your sql is irrelvant to the question. If your sql is creating a proper result set then you need to show us in your code how you are attempting the databinding operations. That appears to be where you are having difficulty, is it not?
rohit ranjan 27-Sep-12 10:00am    
Yes You are right.I need to bind the tree based on level as a node and (userid + name) as description.Please help me in this

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900