I'm trying to loop through a select statement and put the results int oa listbox within a grid.
see below. I cannot get the listbox to populate.
Thanks in advance
Select Case e.Row.RowType
Case DataControlRowType.DataRow
myListBox.BackColor = Drawing.Color.Aqua
Dim sql As String = "select Records from Table WHERE week_number = '" & l1.Text & "'"
Dim connection As New SqlConnection(strcn1)
sCommand = New SqlCommand(sql, connection)
Dim dgDS As New DataSet
Dim dgDA As New SqlDataAdapter(sCommand)
dgDA.Fill(dgDS, "Table")
For Each r As DataRow In dgDS.Tables(0).Rows
myListBox.Items.Add(r("FieldName").ToString())
Next
myListBox.Items.Clear()
myListBox.DataSource = dgDS.Tables("Table")
myListBox.DataBind()
End Select
see below. I cannot get the listbox to populate.
Thanks in advance
Select Case e.Row.RowType
Case DataControlRowType.DataRow
myListBox.BackColor = Drawing.Color.Aqua
Dim sql As String = "select Records from Table WHERE week_number = '" & l1.Text & "'"
Dim connection As New SqlConnection(strcn1)
sCommand = New SqlCommand(sql, connection)
Dim dgDS As New DataSet
Dim dgDA As New SqlDataAdapter(sCommand)
dgDA.Fill(dgDS, "Table")
For Each r As DataRow In dgDS.Tables(0).Rows
myListBox.Items.Add(r("FieldName").ToString())
Next
myListBox.Items.Clear()
myListBox.DataSource = dgDS.Tables("Table")
myListBox.DataBind()
End Select