Wrox Programmer Forums
|
ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Pro Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 22nd, 2003, 10:03 AM
Authorized User
 
Join Date: Aug 2003
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Treeview

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
;)






Similar Threads
Thread Thread Starter Forum Replies Last Post
treeview mahmutmol ASP.NET 2.0 Basics 0 August 21st, 2006 06:43 AM
treeview SAIGORTI SQL Language 2 September 6th, 2005 07:31 PM
TreeView - Please help dotnetprogrammer VS.NET 2002/2003 1 September 5th, 2005 09:02 AM
Treeview dkr72 VBScript 0 November 9th, 2004 12:07 PM
treeview MANOJMETAL ADO.NET 1 April 17th, 2004 08:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.