PDA

Click to See Complete Forum and Search --> : OnSelectedIndexChanged Doesn't work *Resolved*


ahmedabugh
May 8th, 2005, 01:29 PM
hi all;
I have place the following code in a OnSelectedIndexChanged sub..

Here is the 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

mendhak
May 8th, 2005, 07:20 PM
What code do you have for the listbox in the HTML source?

ahmedabugh
May 9th, 2005, 10:39 PM
Hi,

<asp:ListBox id="ListBox1" runat="server" Width="279px" OnSelectedIndexChanged="ListBox1_SelectedIndexChanged" Height="102px"></asp:ListBox>

dj4uk
May 10th, 2005, 04:37 AM
You need to set the AutoPostBack property to true.

HTH

DJ

ahmedabugh
May 12th, 2005, 12:44 AM
you r right, that was my mistake..

Thanks