| | |
dropdownlist not firing
Please support our VB.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?
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...
VB.NET Syntax (Toggle Plain Text)
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...
The code you post has no handler for the SelectedIndexChange event of your drop down control, instead you have a button click handler. So to cause the List box to be rebound, in your programs current state, you need to make a selection in the drop down and then click the submit button every time to get a change in the list box.
Last edited by hollystyles; Apr 23rd, 2007 at 5:02 am.
•
•
Join Date: Mar 2007
Posts: 34
Reputation:
Solved Threads: 0
•
•
•
•
The code you post has no handler for the SelectedIndexChange event of your drop down control, instead you have a button click handler. So to cause the List box to be rebound, in your programs current state, you need to make a selection in the drop down and then click the submit button every time to get a change in the list box.
hope u can help me....your help is very much appreciated...
•
•
•
•
can u elaborate more? i can't figured out where to add the handler?
•
•
•
•
does it mean that i don't need a button click handler?
•
•
Join Date: Mar 2007
Posts: 34
Reputation:
Solved Threads: 0
ok..
i made up my mind that their selection to be actioned immediately they select it in the drop down control...
if so, then i don't need the button right?
so..does it mean that i should add SelectedIndexChanged into my drop down control?
<asp
ropdownlist id=qnum runat="server" DataValueField="QuestionID" DataTextField="QuestionNum" OnSelectedIndexChanged="populateOption()"/>
then at
sub populateOption(......)
--generate OptionList to lstOptions----
am i right until here?
i made up my mind that their selection to be actioned immediately they select it in the drop down control...
if so, then i don't need the button right?
so..does it mean that i should add SelectedIndexChanged into my drop down control?
<asp
ropdownlist id=qnum runat="server" DataValueField="QuestionID" DataTextField="QuestionNum" OnSelectedIndexChanged="populateOption()"/>then at
sub populateOption(......)
--generate OptionList to lstOptions----
am i right until here?
![]() |
Similar Threads
- dropdownlist not firing (ASP.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 VB.NET Forum
- Previous Thread: Reverse a String
- Next Thread: printing current form
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2008 access add application arithmetic array assignment basic box button buttons click code combo component connectionstring convert cpu data database databasesearch datagrid datagridview design designer dissertation dissertations dissertationthesis dosconsolevb.net editvb.net exists file-dialog firewall folder forms hardcopy image images isnumericfuntioncall listview math mobile module mssqlbackend mysql navigate networking number opacity output peertopeervideostreaming picturebox1 picturebox2 port print printpreview problemwithinstallation project record regex reports" reuse right-to-left savedialog serial socket sqldatbase sqlserver storedprocedure string temp text textbox timer toolbox txttoxmlconverter updown useraccounts usercontol usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vbnet view vista visual visualbasic visualbasic.net visualstudio visualstudio.net web wpf wrapingcode xml






