24/05/2005
Hi,
I have created a treeview with a level 'roots'.
I have created a second level child for each root.
My problem is that i see the two levels but not each root with the correspondant child .
the structure of the table TERME is this one
ID_TERME, Lib_TERME
The structure of the table ASSOCIES is this one
ID_TERME_SOURCE_A, ID_TERME_ASSOCIE
Could you help me to order this because it makes a long time i serach about it!!
Thanks a lot for your help
Here is the implemented code
Could you help me please to arrange the situation.
Thanks a lot again for your help always useful.
Cordially.
Nathalie
Hi,
I have created a treeview with a level 'roots'.
I have created a second level child for each root.
My problem is that i see the two levels but not each root with the correspondant child .
the structure of the table TERME is this one
ID_TERME, Lib_TERME
The structure of the table ASSOCIES is this one
ID_TERME_SOURCE_A, ID_TERME_ASSOCIE
Could you help me to order this because it makes a long time i serach about it!!
Thanks a lot for your help
Here is the implemented code
Code:
Imports System.Data
Imports System.Data.SqlClient
Imports Microsoft.Web.UI.WebControls
Imports System.Windows.Forms.TreeNode
Public Class TreeView2
Inherits System.Web.UI.Page
Protected WithEvents TreeView2 As Microsoft.Web.UI.WebControls.TreeView
Protected WithEvents label1_affiche_associé As System.Web.UI.WebControls.Label
Protected WithEvents Label2_affiche_associé As System.Web.UI.WebControls.Label
Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim sConnString As String = "Data Source = localhost ; Initial Catalog =THESAURUS ; User Id =""; Password=""; integrated security = SSPI"
Dim objConn As New SqlConnection(sConnString)
objConn.Open()
Dim objDS As New DataSet()
Dim dt1 As DataTable
Dim dt2 As DataTable
Dim dt3 As DataTable
Dim i As Integer
Dim sbuffer1 As String
Dim sbuffer2 As String
'creation d'un Adapter qui se charge des communications entre le Dataset et la source de données
'autre DataAdapter qui va prendre les enfants de dette racine
Dim da1 As New SqlDataAdapter("SELECT T1.Lib_TERME FROM TERME T1, ASSOCIES WHERE T1.ID_TERME=ASSOCIES.ID_TERME_SOURCE_A", objConn)
da1.Fill(objDS, "ASSOCIES_SOURCE")
dt1 = objDS.Tables("ASSOCIES_SOURCE")
Dim da2 As New SqlDataAdapter("SELECT T2.Lib_TERME FROM TERME T1, TERME T2, ASSOCIES WHERE(T1.ID_TERME = ASSOCIES.ID_TERME_SOURCE_A)and T2.ID_TERME =ASSOCIES.ID_TERME_ASSOCIE", objConn)
'je fais un fill avec un nom de table enfant
da2.Fill(objDS, "ASSOCIES")
dt2 = objDS.Tables("ASSOCIES")
objConn.Close()
'création des types de données du tree view
Dim nodeTERME As TreeNode
Dim rowTERME As DataRow
Dim nodeTERME1 As TreeNode
Dim rowTERME1 As DataRow
For Each rowTERME In objDS.Tables(0).Rows
nodeTERME = New TreeNode()
nodeTERME.Text = rowTERME("Lib_TERME")
TreeView2.Nodes.Add(nodeTERME)
Next
For Each rowTERME1 In objDS.Tables(1).Rows
nodeTERME1 = New TreeNode()
nodeTERME1.Text = rowTERME1("Lib_TERME")
nodeTERME.Nodes.Add(TreeView2.SelectedNodeIndex.)-> here is the problem!!!
Next
End Sub
End Class
Could you help me please to arrange the situation.
Thanks a lot again for your help always useful.
Cordially.
Nathalie