Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Working with treeview - Binding?

Status
Not open for further replies.

zarkon4

MIS
Dec 16, 2003
641
US


I have the following code (please forgive the pasting) to load a treeview control in VB.NET 2005. I know that binding would be the way to go, but how do I bind a dataset to a treeview control with the structure already loaded as follows:
Bldg
Rack
Row
Col
Item
Item
...

My dataset already has the Tree Structure.

Dim strSql As String = "SELECT Bldg, Rack, Row, Col,Item
FROM InventoryLocation ORDER BY Bldg, Rack, Row, Col ,Inv"

Dim MyDataSet As New DataSet
Dim MyDataRow As DataRow

'Get the data and put into a dataset
Using MyConnection As New OdbcConnection(MyConnectionString)
MyConnection.Open()
Using MyDataAdapter As New OdbcDataAdapter(strSql, MyConnection)
MyDataAdapter.Fill(MyDataSet, "InventoryLocation")
End Using
MyConnection.Close()
End Using

'Load the Tree
For Each MyDataRow In MyDataSet.Tables("InvLoc").Rows
'Loop and load the tree 1 record at a time checking for
'changes to the respective nodes: Bldg, Rack, Row, Col
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top