Adding another table to Tree View

J

JJ297

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top