User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 456,479 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,794 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser: Programming Forums
Views: 462 | Replies: 0
Reply
Join Date: Dec 2007
Posts: 9
Reputation: mpatram is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
mpatram mpatram is offline Offline
Newbie Poster

treeview with datagrid

  #1  
Feb 11th, 2008
Hi All,

I m working on a vb.net application. Having a form with treeview & datagrid 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 datagrid control (another SQL Server Table) from a TreeNode Selection. 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=BACKUPAEC;Database=DASE;Trusted_Connection=yes;" 'Connection String
Dim objConn As New SqlConnection(strConn) 'Conection Object

'Dataset Objects
Dim objDS As New DataSet
Dim objDS1 As New DataSet

'DataAdapters
Dim daMEquip1 As New SqlDataAdapter("SELECT distinct GroupName FROM MasterEquipmentConfig", objConn)
Dim daMEquip2 As New SqlDataAdapter("SELECT GroupName, EquipmentName, EquipmentID FROM MasterEquipmentConfig", objConn)

'Fill Dataset
daMEquip1.Fill(objDS, "MasterEquipmentConfig")
daMEquip2.Fill(objDS1, "MasterEquipmentConfig")

objConn.Close() 'Close Connection

Dim nodeGroup, nodeEquip As TreeNode
Dim rowGroup, rowEquip As DataRow

For Each rowGroup In objDS.Tables("MasterEquipmentConfig").Rows
nodeGroup = New TreeNode
nodeGroup.Text = rowGroup("GroupName")
nodeGroup.ForeColor = Color.Blue
TreeView1.Nodes.Add(nodeGroup)


For Each rowEquip In objDS1.Tables("MasterEquipmentConfig").Rows
If rowGroup("GroupName") = rowEquip("GroupName") Then
nodeEquip = New TreeNode
nodeEquip.Text = rowEquip("EquipmentName")
nodeGroup.Nodes.Add(nodeEquip)
End If
Next
Next

objDS.Dispose()
objDS1.Dispose()
daMEquip1.Dispose()
daMEquip2.Dispose()
objConn.Close()
objConn.Dispose()
M Patra
SSE
AISL, India
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb VB.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the VB.NET Forum

All times are GMT -4. The time now is 2:45 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC