| | |
dropdownlist not firing
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
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 |
.net .net2008 2005 2008 access account arithmetic array basic beginner bing browser button buttons center check code combobox crystalreport cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic dropdownlist excel fade file-dialog filter forms ftp generatetags hardcopy html images input insert intel internet mobile monitor ms net networking objects open output panel passingparameters pdf picturebox picturebox1 port position printing problem project save searchvb.net select serial settings shutdown soap sqlserver survey tcp temperature text textbox timer timespan toolbox transparency trim update updown user vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vba vbnet view visual visualbasic.net visualstudio.net visualstudio2008 web winforms wpf wrapingcode year






