| | |
dropdownlist not firing
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
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 alltypeofvideos asp asp.net bc30451 bottomasp.net browser businesslogiclayer button c# c#gridviewcolumn checkbox click commonfunctions compatible confirmationcodegeneration content contenttype countryselector courier css dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deadlock development dgv dropdownlist dropdownmenu edit expose flash flv formatdecimal forms formview gridview homeedition iframe iis javascript jquery list listbox login menu microsoft mono mouse mssql multistepregistration nameisnotdeclared news numerical objects order panelmasterpagebuttoncontrols problem radio ratings reportemail rotatepage save schoolproject search security serializesmo.table silverlight smartcard software sql-server sqlserver2005 suse textbox tracking unauthorized validation vb.net video videos virtualdirectory vista visual-studio visualstudio web webapplications webarchitecture webdevelopemnt webprogramming webservice xml youareanotmemberofthedebuggerusers





