Hi All,
I m working on a vb.net application. Having a form with treeview & propertygrid control. My requirement is that I'll populate the treeview control from a SQL server table. I made this one.
The next task is to populate the propertygrid from another sql server table by selecting the child nodes of treeview. I m not able to find any solution for this. can any one plz help me.
My code for populating the treeview from sql server table is given below
in Form_load
Dim strConn As String = "server=HOME\SQLEXPRESS;database=Li2ns;integrated security=true;"
Dim objConn As New SqlConnection(strConn)
Dim objDS As New DataSet
Dim daSuppliers As New SqlDataAdapter("SELECT CompanyName,SupplierID FROM Supply", objConn)
Dim daProducts As New SqlDataAdapter("SELECT ProductName, ProductID, SupplierID FROM Products", objConn)
daSuppliers.Fill(objDS, "Supply")
daProducts.Fill(objDS, "Products")
objConn.Close()
objDS.Relations.Add("SuppToProd", objDS.Tables("Supply").Columns("SupplierID"), objDS.Tables("Products").Columns("SupplierID"))
Dim nodeSupp, nodeProd As TreeNode
Dim rowSupp, rowProd As DataRow
For Each rowSupp In objDS.Tables("Supply").Rows
nodeSupp = New TreeNode
nodeSupp.Text = rowSupp("CompanyName")
' nodeSupp.ID = rowSupp("SupplierID")
TreeView1.Nodes.Add(nodeSupp)
For Each rowProd In rowSupp.GetChildRows("SuppToProd")
nodeProd = New TreeNode
nodeProd.Text = rowProd("ProductName")
'nodeProd.ID = rowProd("ProductID")
nodeSupp.Nodes.Add(nodeProd)
Next
Next
'clean up
objDS.Dispose()
daSuppliers.Dispose()
daProducts.Dispose()
objConn.Close()
objConn.Dispose()
Plz help me to solve the second task......
Thanks & Regards
MPatra
India