| | |
dropdownlist not firing
Please support our ASP.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
Join Date: Mar 2007
Posts: 34
Reputation:
Solved Threads: 0
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...
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
- dropdownlist not firing (VB.NET)
- GetSelectedIndex Datagrid? Dropdownlist (ASP.NET)
- Help with dropdownlist data adding? (VB.NET)
- DataGrid: Edit mode, the index of a dropdownlist does not start at the right Value (ASP.NET)
- GetSelectedIndex Datagrid? Dropdownlist (C#)
- How do I save an index to a particular index of a dropdownlist in a datagrid. (C#)
- Help With Datagrid RE: Creating and Saving DropDownList ReportsToID (C#)
Other Threads in the ASP.NET Forum
- Previous Thread: Insert Contents Of Text File Into Database
- Next Thread: Error in loading items into a Dropdown list box in an ASP .net Page
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax appliances asp asp.net bc30451 beginner bottomasp.net browser businesslogiclayer c# c#gridviewcolumn cac checkbox class compatible confirmationcodegeneration content contenttype countryselector courier css dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deployment development dgv dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv forms gridview gudi homeedition iframe iis javascript jquery listbox menu mono mssql multistepregistration nameisnotdeclared news novell objects opera problem redirect registration relationaldatabases reportemail rotatepage security serializesmo.table sessionvariables silverlight smartcard smoobjects software sql sql-server ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopemnt webdevelopment webprogramming





