R
Rickey Whitworth
I want to display a treeview control that is tied to a sql database.
The child nodes will be of different types, meaning they will have different
attributes and different tables
-Root
--Service1 (select * from services) value = serviceID = 1
---Database1 (select * from databases where serviceID = ?)
---Website1 (select * from websites where serviceID = ?)
When I click on a node, I want to display attributes of that node in the
right pane. I have handled this before in a windows application by creating
a custom treeNode that has an extra field for type (service, database or
website).
Here is my custom tree node and my enumeration for type
Public Enum NodeType
Service
Application
Database
Website
End Enum
Public Class CustomTreeNode
Inherits TreeNode
Private _ntype As NodeType
Public Property NType() As NodeType
Get
Return _ntype
End Get
Set(ByVal value As NodeType)
_ntype = value
End Set
End Property
Public Sub New(ByVal text As String, ByVal value As String, ByVal
nType As NodeType)
MyBase.New(text, value)
_ntype = nType
End Sub
Public Sub New()
MyBase.New()
End Sub
End Class
And I get an error in this function
Protected Sub TreeView1_TreeNodePopulate(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.TreeNodeEventArgs) Handles
TreeView1.TreeNodePopulate
If e.Node.ChildNodes.Count = 0 Then
Select Case e.Node.Depth
Case 0
FillAuthors(e.Node)
Case 1
FillTitlesForAuthors(e.Node)
Case 2
FillDatabase(e.Node)
End Select
End If
End Sub
Unable to cast object of type 'System.Web.UI.WebControls.TreeNode' to type
'CustomTreeNode'
I'm not really sure how to make this work. I can give more code samples as
needed, but I just need someone who can point me in the right direction. Is
there some other function or property of the treenode I need to override, do
I need to create a custom treeview control and override some event in it?
The child nodes will be of different types, meaning they will have different
attributes and different tables
-Root
--Service1 (select * from services) value = serviceID = 1
---Database1 (select * from databases where serviceID = ?)
---Website1 (select * from websites where serviceID = ?)
When I click on a node, I want to display attributes of that node in the
right pane. I have handled this before in a windows application by creating
a custom treeNode that has an extra field for type (service, database or
website).
Here is my custom tree node and my enumeration for type
Public Enum NodeType
Service
Application
Database
Website
End Enum
Public Class CustomTreeNode
Inherits TreeNode
Private _ntype As NodeType
Public Property NType() As NodeType
Get
Return _ntype
End Get
Set(ByVal value As NodeType)
_ntype = value
End Set
End Property
Public Sub New(ByVal text As String, ByVal value As String, ByVal
nType As NodeType)
MyBase.New(text, value)
_ntype = nType
End Sub
Public Sub New()
MyBase.New()
End Sub
End Class
And I get an error in this function
Protected Sub TreeView1_TreeNodePopulate(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.TreeNodeEventArgs) Handles
TreeView1.TreeNodePopulate
If e.Node.ChildNodes.Count = 0 Then
Select Case e.Node.Depth
Case 0
FillAuthors(e.Node)
Case 1
FillTitlesForAuthors(e.Node)
Case 2
FillDatabase(e.Node)
End Select
End If
End Sub
Unable to cast object of type 'System.Web.UI.WebControls.TreeNode' to type
'CustomTreeNode'
I'm not really sure how to make this work. I can give more code samples as
needed, but I just need someone who can point me in the right direction. Is
there some other function or property of the treenode I need to override, do
I need to create a custom treeview control and override some event in it?