Edited by ADEC: Please remember to close your < code></ code> tags
I have the following code in vb.net that programatically populates a treeview control from a database. The treeview is in the left frame of a page and I want the "incident" child node send a page to the right frame with additional information about the incident that is gathered from the database. How can I set this up so that It will display only that data that pertains to the individual incident that has been clicked.
Any suggestions are greatly appreciated.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
'Put user code to initialize the page here
'Put user code to initialize the page here
Dim strConn As String = "workstation id=localhost;packet size=4096;user
id=Ryan_Ferg;password=_pFerg78;data source=(local);persist security
info=False;initial catalog=incident_data_warehouse"
Dim objConn As New SqlConnection(strConn)
Dim objDS As New DataSet
Dim daCPS As New SqlDataAdapter("SELECT CPS_Name, CPS_UIC FROM
Corps_UICs", objConn)
Dim daDiv As New SqlDataAdapter("SELECT Div_Name, DIV_UIC, CPS_UIC from
Division_UICs", objConn)
Dim daBrigade As New SqlDataAdapter("Select BDE_Name, BDE_UIC, DIV_UIC FROM
Brigade_UICs", objConn)
Dim daBattalion As New SqlDataAdapter("Select BN_Name, BN_UIC, BDE_UIC FROM
Battalion_UICs", objConn)
Dim daCompany As New SqlDataAdapter("Select CO_Name, CO_UIC, BN_UIC from
Company_UICs", objConn)
Dim daIncident As New SqlDataAdapter("Select incident_short_description,
incident_type, incident_date_time, Responsible_UIC from Incident_Transactions",
objConn)
daCPS.Fill(objDS, "dtCorps_UICs")
daDiv.Fill(objDS, "dtDivision_UICs")
daBrigade.Fill(objDS, "dtBrigade_UICs")
daBattalion.Fill(objDS, "dtbattalion_UICs")
daCompany.Fill(objDS, "dtCompany_UICs")
daIncident.Fill(objDS, "dtincident_transactions")
objConn.Close()
objDS.Relations.Add("DivToCps", objDS.Tables("dtCorps_UICs").Columns("CPS_UIC"),
objDS.Tables("dtDivision_UICs").Columns("CPS_UIC"))
objDS.Relations.Add("Brigade", objDS.Tables("dtDivision_UICs").Columns("DIV_UIC"),
objDS.Tables("dtBrigade_UICs").Columns("DIV_UIC"))
objDS.Relations.Add("Battalion", objDS.Tables("dtBrigade_UICs").Columns("BDE_UIC"),
objDS.Tables("dtBattalion_UICs").Columns("BDE_UIC"))
objDS.Relations.Add("Company", objDS.Tables("dtBattalion_UICs").Columns("BN_UIC"),
objDS.Tables("dtCompany_UICs").Columns("BN_UIC"))
objDS.Relations.Add("Incident", objDS.Tables("dtCompany_UICs").Columns("CO_UIC"),
objDS.Tables("dtincident_transactions").Columns("Responsible_UIC"))
Dim nodeSupp, nodeProd, Nodebde, NodeBN, NodeCO, NodeIncident As TreeNode
Dim rowSupp, rowProd, rowincident As DataRow
Dim rowbde, rowbn, rowco As DataRow
For Each rowSupp In objDS.Tables("dtCorps_UICs").Rows
nodeSupp = New TreeNode
nodeSupp.Text = rowSupp("CPS_Name")
nodeSupp.ID = rowSupp("CPS_UIC")
TreeView1.Nodes.Add(nodeSupp)
For Each rowProd In rowSupp.GetChildRows("DivToCps")
nodeProd = New TreeNode
nodeProd.Text = rowProd("Div_Name")
nodeProd.ID = rowProd("DIV_UIC")
nodeSupp.Nodes.Add(nodeProd)
For Each rowbde In rowProd.GetChildRows("Brigade")
Nodebde = New TreeNode
Nodebde.Text = rowbde("BDE_Name")
nodeProd.ID = rowbde("BDE_UIC")
nodeProd.Nodes.Add(Nodebde)
For Each rowbn In rowbde.GetChildRows("Battalion")
NodeBN = New TreeNode
NodeBN.Text = rowbn("BN_Name")
NodeBN.ID = rowbn("BN_UIC")
Nodebde.Nodes.Add(NodeBN)
For Each rowco In rowbn.GetChildRows("Company")
NodeCO = New TreeNode
NodeCO.Text = rowco("CO_Name") & " " & "-" & rowco.GetChildRows
("incident").Length & " " & " " & "Incidents"
NodeCO.ID = rowco("CO_UIC")
NodeBN.Nodes.Add(NodeCO)
For Each rowincident In rowco.GetChildRows("incident")
NodeIncident = New TreeNode
NodeIncident.Text = rowincident("incident_short_description") & " "
& " " & " -- " & rowincident("incident_date_time")
NodeIncident.ID = rowincident("incident_type")
NodeCO.Nodes.Add(NodeIncident)
NodeIncident.NavigateUrl = "webform4.aspx"
NodeIncident.Target = "main"
Next
Next
Next
Next
Next
Next
objDS.Dispose()
daCPS.Dispose()
daDiv.Dispose()
daBrigade.Dispose()
objConn.Close()
objConn.Dispose()
End Sub
End Class