Hi,
I have a webform with a treeview. The tree is populated from the db (Category table). When a user clicks a node then I want to get the corresponding Product name from the products table in the db.
Below is the code that I tried. It does postback but does't fill the label.
Private Sub TreeView5_SelectedIndexChange(ByVal sender As Object, ByVal e As Microsoft.Web.UI.WebControls.TreeViewSelectEventArgs) Handles TreeView5.SelectedIndexChange
Dim objConn As New SqlConnection(strConn)
objConn.Open()
Dim objDS As New DataSet
cmd = objConn.CreateCommand
cmd.CommandText = "SELECT * FROM CATEGORIES WHERE CATEGORYID=@CATID"
cmd.Parameters.Add("@CATID", TreeView5.GetNodeFromIndex(e.NewNode).ID)
Dim dr As SqlDataReader
dr = cmd.ExecuteReader
Do While dr.Read
Label3.Text = dr.Item("CategoryName") + "<br>"
Loop
objConn.Close()
End Sub