what is wrong with my code?
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load MyConnection.Open() Dim strSQL As String = "SELECT * FROM Question WHERE SurveyID=83 Order By QuestionNum" Dim cnCommand1 As SqlCommand = New SqlCommand(strSQL, MyConnection) Dim Rdr As SqlDataReader = cnCommand1.ExecuteReader() 'execute reader to catch data from db to drop dwon lists With qnum .DataSource = Rdr .DataValueField = "QuestionID" .DataTextField = "QuestionNum" .DataBind() End With 'Rdr.NextResult() 'With lstOptions ' .DataSource = Rdr ' .DataValueField = "OptionID" ' .DataTextField = "OptionList" ' .DataBind() 'End With 'close the reader Rdr.Close() End Sub Sub SubmitBtn_Click(ByVal sender As Object, ByVal e As EventArgs) Dim questid As String = qnum.SelectedItem.Value For Each s As String In questid Dim sql As String = "SELECT * From AnswerList WHERE SurveyID=83 AND QuestionID='" & questid & "' Order By QuestionNum" Dim cmd As SqlCommand = New SqlCommand(sql, MyConnection) Dim reader As SqlDataReader reader = cmd.ExecuteReader With lstOptions .DataSource = reader .DataValueField = "OptionID" .DataTextField = "OptionList" .DataBind() End With reader.Close() Next 'Close the DB Connection MyConnection.Close() End Sub
i want to populate the lstOptions (a listbox) based on the item selected in frop down list named "qnum"
the problem is..the data in lstOptions changed only at first time the dropdown list value change...the 2nd,3rd change of the dropdownlist, the lstOptions value doesn't change
plzz help me...