OnSelectedIndexChanged Doesn't work *Resolved*
hi all;
I have place the following code in a OnSelectedIndexChanged sub..
Here is the code...
VB Code:
Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs)
LISTBOX2.ITEMS.CLEAR
dim selectstring as string
Dim cn1 As OleDbConnection = New OleDbConnection(ConfigurationSettings.appSettings("connectionstring"))
cn1.Open()
selectString = "select question_id, Question from questions where exam_id = " & listbox1.selecteditem.value
Dim cmd1 As OleDbCommand = New OleDbCommand(selectString, cn1)
Dim reader1 As OleDbDataReader = cmd1.ExecuteReader()
dim liadd as listitem
while(reader1.read())
liadd = new listitem
liadd.text = reader1("question").tostring
liadd.value = reader1("question_id").tostring
listbox2.items.add(liadd)
end while
End Sub
But it doesn't work. As you can see it must refresh the values of a list box, but simply nothing happens...
Is there a mistake somewher ????
Thanks
Re: OnSelectedIndexChanged Doesn't work
What code do you have for the listbox in the HTML source?
Re: OnSelectedIndexChanged Doesn't work
Hi,
VB Code:
<asp:ListBox id="ListBox1" runat="server" Width="279px" OnSelectedIndexChanged="ListBox1_SelectedIndexChanged" Height="102px"></asp:ListBox>
Re: OnSelectedIndexChanged Doesn't work
You need to set the AutoPostBack property to true.
HTH
DJ
Re: OnSelectedIndexChanged Doesn't work
you r right, that was my mistake..
Thanks