Say I have a listbox lb, which I initialize using:
lb.DataSource = wordList \\wordList is a list of strings
lb.DataBind()
The listbox is initialized perfectly, and everything that should appear there does.
However, now I select one of items in the listbox with my mouse (coloring it dark blue, in case anyone wondered what I meant in “select”), and perform the following test:
If lb.SelectedIndex <> -1 Then
DoSomething()
EndIf
or the test:
If Not lb.SelectedItem Is Nothing Then
DoSomething()
EndIf
etc..
Either way, when debugging it keeps not entering the if blocks, claiming of course that
lb.selectedindext IS -1, lb.SelectedItem IS nothing, and so on.
What am I doint wrong? Why doesn’t it recognise my selections??
10x
It’s possible that you do the DataBind() of the listBox also in the postback?
Maybe you need to put it (the binding) in a
to ensure you’re not losing your client’s select.