Adding another table to Tree View

Discussion in 'ASP .Net' started by JJ297, Aug 28, 2007.

  1. JJ297

    JJ297 Guest

    Could someone please tell me how to add another table to my code for
    my tree view?
    I want to add a table called Media and use the field description as
    another child

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles Me.Load
    If Not Page.IsPostBack Then

    Dim myconn As New Data.SqlClient.SqlConnection
    Dim mycommand As New Data.SqlClient.SqlCommand

    myconn.ConnectionString =
    ConfigurationManager.ConnectionStrings("TrainUserConnectionString").ConnectionString
    myconn.Open()

    Dim daClassifications As New Data.SqlClient.SqlDataAdapter
    Dim sqlcom As New Data.SqlClient.SqlCommand
    With sqlcom
    .Connection = myconn
    .CommandType = CommandType.StoredProcedure
    .CommandText = "GetClassifications"
    End With

    daClassifications.SelectCommand = sqlcom
    Dim sqlcom1 As New Data.SqlClient.SqlCommand
    With sqlcom1
    .Connection = myconn
    .CommandType = CommandType.StoredProcedure
    .CommandText = "GetListing"
    End With

    Dim daTitle As New Data.SqlClient.SqlDataAdapter
    daTitle.SelectCommand = sqlcom1
    Dim dsFaq As New dsFaw
    daclassifications.Fill(dsFaq, "Classifications")
    daTitle.Fill(dsFaq, "Title")


    dsFaq.Relations.Add("TopToQues",
    dsFaq.Tables("Classifications").Columns("ClassificationID"),
    dsFaq.Tables("Title").Columns("classificationid"))
    Dim nodeTop, nodeQues, nodeAns As TreeNode

    Dim rowTop, rowQues As DataRow

    For Each rowTop In dsFaq.Tables("classifications").Rows

    nodeTop = New TreeNode

    nodeTop.Text = rowTop("description")

    TreeView1.Nodes.Add(nodeTop)

    For Each rowQues In rowTop.GetChildRows("TopToQues")

    nodeQues = New TreeNode

    nodeQues.Text = rowQues("Title")

    nodeTop.ChildNodes.Add(nodeQues)

    nodeAns = New TreeNode

    nodeAns.Text = rowQues("description")

    nodeQues.ChildNodes.Add(nodeAns)

    Next

    Next

    End If
    End Sub
    JJ297, Aug 28, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stub

    B tree, B+ tree and B* tree

    Stub, Nov 12, 2003, in forum: C Programming
    Replies:
    3
    Views:
    10,097
  2. Peter Mueller
    Replies:
    6
    Views:
    4,534
    Stefan Ram
    Jan 13, 2008
  3. raki
    Replies:
    1
    Views:
    1,119
    Alexey Smirnov
    Jun 24, 2009
  4. Peter Reimer
    Replies:
    4
    Views:
    1,104
    Peter Flynn
    Apr 12, 2010
  5. Parthiv Joshi
    Replies:
    1
    Views:
    649
    Samuel L Matzen
    Jul 6, 2004
Loading...

Share This Page