Treeview ctl Populating SQL Data

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Treeview ctl Populating SQL Data

    I'm using the MS Treeview Control Version 5 (SP2), comctl32.ocx in an .ASP
    (IIS 6) page using ADO to populate data from a SQL 2000 DB.
    Their are 2 columns I'm working with. "Communities" and "ProjectNumber" in
    one talble named Allprojects.
    Their can be multiple ProjectNumbers for each Community which are unique to
    that Community, so my tree should look as such:

    - --Community1
    | |___ProjectNumber1
    | |___ProjectNumber2
    | |___ProjectNumber3
    |
    - --Community2
    | |___ProjectNumber4
    | |___ProjectNumber5
    | |___ProjectNumber6
    + --Community3
    + --Community4
    + --Community5

    The problem I'm having is that I can only get one ProjectNumber to populate
    as child Node under each Parent Node (Community) which looks like this:

    - --Community1
    | |___ProjectNumber1
    |
    - --Community2
    | |___ProjectNumber4
    |
    + --Community3
    + --Community4
    + --Community5

    Here is the Code I'm using. I really need some help here. I've exhausted all
    resources:

    <%
    '************ Construct SQL Statement ******************************

    sSQL = "SELECT DISTINCT Community from AllProjects ORDER BY Community
    ASC"
    '************ Create Connection and Recordset **********************

    Set cnn = Server.CreateObject("Adodb.connection")
    cnn.open "DSN=PMwater", "sa"
    Set Rs = Server.CreateObject("adodb.recordset")
    Set Rs = cnnPubs.execute(sSQL)
    Set objComm = Rs("Community")

    '************ Populate the Control ******************************

    Set objCommIX = objComm'TreeView1.Nodes.Add , , & Chr(34) & objComm &
    Chr(34) & Chr(34) &_


    Do While Not rstCustomers.EOF
    Response.write "TreeView1.Nodes.Add , , " & Chr(34) &
    objComm & Chr(34) & "," & Chr(34) &_
    objComm & Chr(34) & chr(10) & chr(13)

    objIX = "select ProjectNumber from AllProjects where Community =" & Chr(39)
    & objComm & Chr(39) & chr(10) & chr(13)

    Set Rs1 = cnnPubs.execute(objIX)

    'Add author to root node.
    '********* Add the titles as a child node to the author *****
    Response.Write Chr(10) & "TreeView1.Nodes.Add " & Chr(34) & _
    objComm & Chr(34) & ", 4, ," & Chr(34) & _
    Rs1(0) & Chr(34) & chr(10) & chr(13)
    Rs.MoveNext
    Loop


    %>


    Troy Jerkins Guest

  2. Similar Questions and Discussions

    1. popup datagrid not populating data from xml
      hey guys, im having trouble creating a datagrid within a popup. i created the datagrid on a normal panel and everything worked fine. then i tried...
    2. Populating DataGrid with nested data
      Hello, I'm new to Flex and I'm having a hard time populating a dataGrid with info nested in an dynamically updatable XMLListCollection. for...
    3. #39647 [NEW]: Not populating $_POST data
      From: security at isnnetworks dot net Operating system: Linux, Centos 4.4 PHP version: 5.2.0 PHP Bug Type: *General Issues...
    4. Populating DataGrid with data ...
      It seems that DataGrid supports dynamic data loading only from global variables. In my case, I have something like this: "code below", where...
    5. populating dropdowns with sql data
      I'm trying to find info on how to build a list box from mysql data. This part I can find many tutorials on however, I'm creating a form to edit all...
  3. #2

    Default RE: Treeview ctl Populating SQL Data

    Hello Troy,

    Thanks for posting in the group.

    Based on my understanding, now you are retrieving data from database and
    populating it in a treeview control in client side scripting. However, for
    some reason, you can only show one child node in treeview. Is it right?

    In MSDN, there is a KB article which demonstrates exactly the same question
    as yours. Please refer to:
    "HOWTO: Populate an ActiveX TreeView Control Using ASP"
    [url]http://support.microsoft.com/?id=183329[/url]

    This article describes how to use Active Server Pages (ASP) code to
    populate an ActiveX TreeView control. The technique shown here leverages
    ASP's ability to dynamically build a VBScript function to populate a
    client-side ActiveX control, based on results retrieved through ActiveX
    Database Objects (ADO).

    I have tested the sample code in the KB article and it works fine.

    Hope that helps.

    Best regards,
    Yanhong Huang
    Microsoft Community Support

    Get Secure! ¨C [url]www.microsoft.com/security[/url]
    This posting is provided "AS IS" with no warranties, and confers no rights.

    Yan-Hong Huang[MSFT] Guest

  4. #3

    Default Re: Treeview ctl Populating SQL Data

    Thanks for the reply. I had seen that Article before, but never tried to
    actually run that piece of code against the Pubs DB.
    Once I did and started to see what was happening in the script debugger, I
    realized I need to add a column to my table that uniquely identified the
    parent nodes key value.
    After that everything clicked. Thanks again!!

    -Troy

    "Yan-Hong Huang[MSFT]" <yhhuang@online.microsoft.com> wrote in message
    news:diTUz0P9DHA.2052@cpmsftngxa07.phx.gbl...
    > Hello Troy,
    >
    > Thanks for posting in the group.
    >
    > Based on my understanding, now you are retrieving data from database and
    > populating it in a treeview control in client side scripting. However, for
    > some reason, you can only show one child node in treeview. Is it right?
    >
    > In MSDN, there is a KB article which demonstrates exactly the same
    question
    > as yours. Please refer to:
    > "HOWTO: Populate an ActiveX TreeView Control Using ASP"
    > [url]http://support.microsoft.com/?id=183329[/url]
    >
    > This article describes how to use Active Server Pages (ASP) code to
    > populate an ActiveX TreeView control. The technique shown here leverages
    > ASP's ability to dynamically build a VBScript function to populate a
    > client-side ActiveX control, based on results retrieved through ActiveX
    > Database Objects (ADO).
    >
    > I have tested the sample code in the KB article and it works fine.
    >
    > Hope that helps.
    >
    > Best regards,
    > Yanhong Huang
    > Microsoft Community Support
    >
    > Get Secure! ¨C [url]www.microsoft.com/security[/url]
    > This posting is provided "AS IS" with no warranties, and confers no
    rights.
    >

    Troy Jerkins Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139