Hello,
I created a PO_TreeNode class inheriting TreeNode and I filled the first level of Treeview with that class.
I will like to dynamically fill the second level of the Treeview when the user clicks on the tree structure because I have an access to a database for each node and if I filled all the Treeview with the loading it is very long.
The function which filled the tree structure is as follows
Private Sub addChildNode(ByRef parentNode As PO_TreeNode, ByVal con As System.Data.OracleClient.OracleConnection)
Dim sql As String
Dim childSortOf As String
Dim cmd As System.Data.OracleClient.OracleCommand
Dim Rd As System.Data.OracleClient.OracleDataReader
Dim node As PO_TreeNode
If parentNode.sqlToGetChildren <> "" Then
Try
cmd = New System.Data.OracleClient.OracleCommand(parentNode.sqlToGetChildren, con)
Rd = cmd.ExecuteReader()
Catch ex As Exception
Me.ErrorMsg.Text = Me.ErrorMsg.Text & "Erreure de lecture des données Oracle : " & ex.Message & cmd.CommandText
Exit Sub
End Try
While Rd.Read()
node = New PO_TreeNode(Rd.GetValue(0), parentNode.Text, parentNode.parentName, parentNode.parentSortOf, con)
parentNode.ChildNodes.Add(node)
End While
End If
End Sub
The loading of the first level goes very well
But when I execute the function
Public Sub TreeView_ItemClick(ByVal sender As System.Object, ByVal e As EO.Web.NavigationItemEventArgs) Handles TreeView.ItemClick
addChildNode(e.TreeNode, con)
End Sub
I get an Invalid Cast Exception
How to recover the PO_TreeNode class in the TreeView_ItemClick function
Cheers,
Patrice Bailly