Populating Treeview from DB - Stops at 3rd level
Visual Basic
1
Posts
1
Posters
0
Views
1
Watching
-
This is probably more of a beginner issue, but Im trying to populate a treeview based off the Northwind Database. The Top level is a list of countries, second level is a list of customers from that country, and 3rd level is supposed to be orderids from that country but it isnt populating. I know its stopping at my 'FillOrderIDs' but I cant seem to figure out why. I appreciate any advice,
Private Sub FillCountries() Dim tcountry As String Dim tnode As TreeNode Dim tCountryTable As NorthwindDataSet.CountriesDataTable tCountryTable = Me.CountriesTableAdapter.GetCountriesData For Each trow As NorthwindDataSet.CountriesRow In tCountryTable tcountry = trow.Country tnode = New TreeNode tnode.Name = "Country" tnode.Text = tcountry Me.TreeView1.TopNode.Nodes.Add(tnode) FillCompanyNames(tcountry, tnode) Next End Sub Private Sub FillCompanyNames(ByVal country As String, ByVal parentnode As TreeNode) Dim tCompany As String Dim tnode As TreeNode Dim CustTable As NorthwindDataSet.CompanyNamesDataTable CustTable = Me.CompanyNamesTableAdapter.GetCustomersByCountry(country) For Each trow As NorthwindDataSet.CompanyNamesRow In CustTable tCompany = trow.CompanyName tnode = New TreeNode tnode.Name = "CompanyName" tnode.Text = trow.CompanyName tnode.Tag = trow.CompanyName parentnode.Nodes.Add(tnode) FillOrderIDs(tCompany, tnode) Next End Sub Private Sub FillOrderIDs(ByVal orderid As String, ByVal parentnode As TreeNode) Dim tnode As TreeNode Dim OrdTable As NorthwindDataSet.OrderIdsDataTable OrdTable = Me.OrderIdsTableAdapter.GetOrderIds(CompanyName) For Each trow As NorthwindDataSet.OrderIdsRow In OrdTable tnode = New TreeNode tnode.Name = "OrderID" tnode.Text = trow.OrderID tnode.Tag = trow.OrderID parentnode.Nodes.Add(tnode) Next End Sub Private Sub btnDisplay\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click TreeView1.Nodes.Add("Countries") FillCountries() End Sub