Treeview Display Image on Node Click

D

dan

Hello Eveyone,

Your help would be appriciated in regards to the following -

I have a treeview that is populated via an access db (code below) that
works fine.

What I am trying to do is get it to show a picture of a part (not in
the tree view but elsewhere in the page) when the last node is clicked
in a group.

I have searched high and low but unfortunately I cannot find the right
combination or documentation.

I am using dreamweaver MX2004, web matrix, and have access to VS 2003.

Your help is greatly appriciated.

My Code:

<%@ Page Language="VB" Debug="true" %>
<%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls"
Assembly="Microsoft.Web.UI.WebControls" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">

Sub Page_Load(Sender As Object, E As EventArgs)

If Not IsPostback Then

'Database Connection
Dim ConnectionString As String =
"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Inetpub\wwwroot\dbtest\data\bestdata2.mdb;User ID=admin"

'SQL Statements
Dim strCarModel As String = "SELECT * FROM CarModelTbl"
Dim strCat1 As String = "SELECT * FROM Cat1Tbl"
Dim strCat2 As String ="SELECT * FROM Cat2Tbl"
Dim strParts As String = "SELECT * FROM PartsTbl"

Dim myConnection As New OleDbConnection(ConnectionString)

'Setup Datasets
Dim daCarModel As New OleDbDataAdapter(strCarModel,
myConnection)
Dim daCat1 As New OleDbDataAdapter(strCat1, myConnection)
Dim daCat12 As New OleDbDataAdapter(strCat1, myConnection)
Dim daCat2 As New OleDbDataAdapter(strCat2, myConnection)
Dim daParts As New OleDbDataAdapter(strParts, myConnection)

'Setup Releationship Datasets
Dim objDS As New DataSet

'Fill relationship Datasets
daCarModel.Fill(objDS, "dtCarModel")
daCat1.Fill(objDS, "dtCat1")
daCat2.Fill(objDS, "dtCat2")
daParts.Fill(objDS, "dtParts")

'Closeing Connection
myConnection.Close()

'First Relationship
objDS.Relations.Add("CarModelToCat1", _
objDS.Tables("dtCarModel").Columns("CarModelID"), _
objDS.Tables("dtCat1").Columns("CarModelID"))

'Second Relationship
objDS.Relations.Add("Cat1ToCat2", _
objDS.Tables("dtCat1").Columns("Cat1ID"), _
objDS.Tables("dtCat2").Columns("Cat1ID"))

'Third Releationship
objDS.Relations.Add("Cat2ToParts", _
objDS.Tables("dtCat2").Columns("Cat2ID"), _
objDS.Tables("dtParts").Columns("Cat2ID"))

'Tree View Nodes and DataRows
Dim nodeCarModel, nodeCat1, nodeCat2, nodeParts As TreeNode
Dim rowCarModel, rowCat1, rowCat2, rowParts As DataRow

'Building the trees

'Root
For Each rowCarModel In objDS.Tables("dtCarModel").Rows
nodeCarModel = New TreeNode
nodeCarModel.Text = rowCarModel("CarModelName")
nodeCarModel.ID = rowCarModel("CarModelID")
TreeView1.Nodes.Add(nodeCarModel)

'SubTree 1
For Each rowCat1 In
rowCarModel.GetChildRows("CarModelToCat1")
nodeCat1 = New TreeNode
nodeCat1.Text = rowCat1("Cat1Name")
nodeCat1.ID = rowCat1("Cat1ID")
nodeCarModel.Nodes.Add(nodeCat1)

'Subtree 2
For Each rowCat2 In
rowCat1.GetChildRows("Cat1ToCat2")
nodeCat2 = New TreeNode
nodeCat2.Text = rowCat2("Cat2Description")
nodeCat2.ID = rowCat2("Cat2ID")
nodeCat1.Nodes.Add(nodeCat2)

'subtree 3
For Each rowParts In
rowCat2.GetChildRows("Cat2ToParts")
nodeParts = New TreeNode
nodeParts.Text = rowParts("PartNumber") & " - "
& ("PartDescription")
nodeParts.ID = rowParts("PartsID")
nodeCat2.Nodes.Add(nodeParts)

Next
Next
Next
Next

'clean up
objDS.Dispose()
daCarModel.Dispose()
daCat1.Dispose()
daCat2.Dispose()
daParts.Dispose()

End If

End Sub

</script>
<html>
<head>
</head>
<body style="FONT-FAMILY: arial">
<form runat="server">
<iewc:TreeView id="TreeView1" runat="server"
AutoPostBack="True"></iewc:TreeView>

</form>

<p>&nbsp;</p>
<p><img id="DetailsImage" visible="false" runat="server">
</p>
</body>
</html>
 

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,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top