Hi
I want to display the department hierarchy in a treeview control on an asp page. I've looked through previos posts and seen people using one from Planetsourcecode. I've tried using that but I don't know how many levels will be used so I'm using the standard microsoft one. I have got it all working in
VB and need to transpose it to ASP.
I've used the following code and it just prints the code that needs to be in the Treeview.
<html>
<body>
<% BuildTree()%>
<OBJECT id=TreeView1 style="LEFT: 0px; WIDTH: 325px; TOP: 0px; HEIGHT: 700px" classid="clsid:C74190B6-8589-11D1-B16A-00C0F0283628">
<PARAM NAME="_ExtentX" VALUE="9260">
<PARAM NAME="_ExtentY" VALUE="18521">
<PARAM NAME="_Version" VALUE="393217">
<PARAM NAME="HideSelection" VALUE="0">
<PARAM NAME="Indentation" VALUE="741">
<PARAM NAME="LabelEdit" VALUE="1">
<PARAM NAME="LineStyle" VALUE="0">
<PARAM NAME="PathSeparator" VALUE="\">
<PARAM NAME="Sorted" VALUE="1">
<PARAM NAME="Style" VALUE="6">
<PARAM NAME="Checkboxes" VALUE="0">
<PARAM NAME="FullRowSelect" VALUE="0">
<PARAM NAME="HotTracking" VALUE="0">
<PARAM NAME="Scroll" VALUE="1">
<PARAM NAME="SingleSel" VALUE="0">
<PARAM NAME="ImageList" VALUE="">
<PARAM NAME="BorderStyle" VALUE="0">
<PARAM NAME="Appearance" VALUE="0">
<PARAM NAME="MousePointer" VALUE="0">
<PARAM NAME="Enabled" VALUE="1">
<PARAM NAME="OLEDragMode" VALUE="0">
<PARAM NAME="OLEDropMode" VALUE="0">
</OBJECT>
</body>
</html>
<%
Sub BuildTree()
Dim nde
ssql = "select min(user_id) as min_user from users"
Set cnn = Server.CreateObject("Adodb.connection")
cnn.open "DSN=AWOL_Test", "sa"
Set rcst = Server.CreateObject("adodb.recordset")
Set rcst = cnn.execute(sSQL)
'Set nde = TreeView1.Nodes.Add(, , "_-1", "ROOT")
Response.Write "TreeView1.Nodes.Add(,,'_-1','AWOL')"
nde = "_-1"
users nde
rcst.Close
Set rcst = Nothing
cnn.close
set cnn = nothing
End Sub
Sub users(user_node)
'user_id = Right(user_node.Key, Len(user_node.Key) - 1)
user_id = right(user_node,len(user_node) -1)
ssql = "select user_id, first_name, last_name from users where manager_id =" & user_id
Set cnn = Server.CreateObject("Adodb.connection")
cnn.open "DSN=AWOL_Test", "sa"
Set rs = Server.CreateObject("adodb.recordset")
Set rs = cnn.execute(sSQL)
Do While Not rs.EOF
strSQL = "select count(manager_id) as count_manager from users where manager_id = " & rs("user_id")
Set rst = Server.CreateObject("adodb.recordset")
Set rst = cnn.execute(strSQL)
Dim nod
'Set nod = TreeView1.Nodes.Add(user_node.Key, tvwChild, "_" & rst("user_id"), rst("first_name") & " " & rst("last_name"))
Response.Write "TreeView1.Nodes.Add(" & user_id & ", tvwChild, _" & rs("user_id") & "," & rs("first_name") & " " & rs("last_name") & ")"
If rst("count_manager") > 0 Then
users "_" & rs("user_id")
End If
rst.Close
Set rst = Nothing
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
cnn.Close
set cnn = nothing
End Sub
%>
and I get the following...
TreeView1.Nodes.Add(,,'_-1','AWOL')TreeView1.Nodes.Add(-1, tvwChild, _0,AWOL)TreeView1.Nodes.Add(0, tvwChild, _24,A)TreeView1.Nodes.Add(24, tvwChild, _23,1)TreeView1.Nodes.Add(24, tvwChild, _38,2)TreeView1.Nodes.Add(38, tvwChild, _33,3).....
Can anyone help?
Thanks
Lbob
;)