Hi I am using the following code to populate text boxes based on a drop down list index change event
Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As WinControls.UI.Data.PositionChangedEventArgs) Handles DropDownList1.SelectedIndexChanged
Dim connString As String = My.Settings.strConn
Dim conn As New SqlConnection(connString)
Try
conn.Open()
Dim qry As String = "select * from property where propRef='" + RadDropDownList1.SelectedText + "'"
Dim cmd As New SqlCommand(qry, conn)
Dim dr As SqlDataReader = cmd.ExecuteReader()
If dr.Read() Then
TextBoxHouseNo.Text = dr(3)
TextBoxStreet.Text = dr(4)
TextBoxCity.Text = dr(5)
TextBoxPostCode.Text = dr(6)
TextBoxRent.Text = dr(12)
End If
dr.Close()
Catch ex As Exception
Finally
conn.Close()
End Try
End Sub
The code works until it gets to the last item if there is only one item in the dropdown box it does not populate the text boxes, if I loop through the code it is going to the droplist index change but it goes from dr.Read() and just jumps to dr.close() without populating the text boxes?
any suggestions
tahnks
M