I have a Tree view and i have to fill with database As category and subcategory , as per node and child .... Could any one help me ..,,,, with a very good example
Loading
I have a Tree view and i have to fill with database As category and subcategory , as per node and child .... Could any one help me ..,,,, with a very good example
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
ArshadPosted Sep 15, 2008, 2:27 PM
dsData.Relations.Add("relationA", dsData.Tables(0).Columns("Categoryid"), dsData.Tables(1).Columns("Categoryid")) After that Please check the code that has given below
Dim nodeCatName, nodeSubCatName As TreeNode
Dim rowCatName, rowSubCatName As DataRow
For Each rowCatName In dsData.Tables(0).Rows
nodeCatName = New TreeNode
nodeCatName.Text = rowCatName("CategoryName")
nodeCatName.Selected = True
nodeCatName.Collapse()
nodeCatName.SelectAction = TreeNodeSelectAction.Expand
trvDisplayGroup.Nodes.Add(nodeCatName)
For Each rowSubCatName In rowCatName.GetChildRows("relationA")
nodeSubCatName = New TreeNode
nodeSubCatName.Text = rowSubCatName("SubCategoryName")
nodeSubCatName.Selected = True
nodeCatName.ChildNodes.Add(nodeSubCatName)
nodeCatName.Expand()
Next
Next
Thats all, it will give you SubCategory under the Category.Thats all