thanks a lot for yours help!
Imar, I don't use C# so... I can't use anonymous delegate. I saw examples like these on my web searches but couldn't make this work on
VB.
I spent all my afternoon with this!
With my first solution (That I wrote here) I saw that i make a postback every time that I click on treeview "+" (demand Icon).
And only then the treeview bind subcategories.
With a small change off code I have what I want!
Code:
Private Sub BindTreeView()
Dim CategTable As DataTable = MySite.BLL.Articles.Category.GetCategoriesTable()
PopulateNodes(CategTable, tvCategories.Nodes, 0)
End Sub
Private Sub PopulateNodes(ByVal dt As DataTable, _
ByVal nodes As TreeNodeCollection, ByVal Parent As Integer)
For Each dr As DataRow In dt.Rows
If dr("ParentID") = Parent Then
Dim tn As New TreeNode()
tn.Text = dr("Name").ToString()
tn.Value = dr("CategoryID").ToString()
nodes.Add(tn)
If dt.Select("ParentID=" & dr("CategoryID").ToString()).Length > 0 Then
PopulateNodes(dt, tn.ChildNodes, dr("CategoryID").ToString())
End If
End If
Next
End Sub
With this I don't have postback on my treeview!
But I don't know if it is good politic have a function call inside this same function!
The solution worked but I'll appreciate your opinion about this!
BTW I used "DataTable" just for test... I could a list(of T) with a double "for" to do the same like we conclude some posts earlier
Thanks one more time!