944,161 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 1680
  • ASP.NET RSS
Apr 23rd, 2007
0

dropdownlist not firing

Expand Post »
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...
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
shy_wani is offline Offline
34 posts
since Mar 2007
Apr 23rd, 2007
0

Re: dropdownlist not firing

Try replacing qnum.SelectedItem.Value with qnum.SelectedValue
Reputation Points: 12
Solved Threads: 11
Junior Poster in Training
ManicCW is offline Offline
95 posts
since Nov 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Insert Contents Of Text File Into Database
Next Thread in ASP.NET Forum Timeline: Error in loading items into a Dropdown list box in an ASP .net Page





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC