I have a table emp-mst and i need some help as in my intranet project i make a stored procedure like if i pass any employee id then it shows the name and id of the persons that working under the login person now i want to show this data(result of sp) in hierarchical form in a asp.net page.
my sp name is usp_reportingperson.
means if i am login then it shows the employee under working me if no employee is working under then there will be no plus sign to expand if working then + sign must show to expand and the employee working under me also having employees then also a plus sign with their name
please help its urgent
please provide the code.
Loading
Rakesh JhaPosted Sep 29, 2011, 2:35 AM
actually you can implement the code from the below link, just use only parent node code not implement child node code
http://www.codeproject.com/KB/aspnet/DataTreeView.aspx
it is very easy sample, you can easily write your code to display data from sp returned values.
sunakshi saxenaPosted Sep 29, 2011, 2:27 AM
Pravin MorePosted Sep 29, 2011, 1:13 AM
i had gone through same requirment.......here is logic.....
make your sproc query recursive....return one more column from query whose value will be 1 0r 0 depend on that employee have any other emp working under him.....n while binding to treeview check if that emp have value 1 then add '+' sign else dont add............
write query like ......
create procedure GetEMPUNDER @ID int as
begin
select eid,ename, case when (select count (eid) from emp_mst where workingforID=abc.ID) > 0 then 1 else 0 end as idUnder
from (select eid,ename from emp_mst where workingforID=@ID) abc
end
so, your sproc now return three clumns 1 is eid 2nd is Ename and other isUnder (1 or 0) then check while bilnding like i explained..........
just bind ename to treeview and on click of node call sproc with ID of that node as parameter
i hope you will get solution.
Thanx,
Pravin.