listbox not allowing 1st selection

  • Thread starter Thread starter tshad
  • Start date Start date
T

tshad

I have a listbox that I fill and can't select the 1st item until I select
another item first.

I have the onselectedindexchange set to a function and autopostback set to
true.

The only problem is that it doesn't go to the function if I select the first
item. It does the postback, but doesn't go to the function until I select
something else first 2nd item or greater (which goes to the
onSelectedIndexChange function. Then I can select the 1st item fine.

I tried setting Search.SelectedIndex to -1 first, but that didn't seem to
help.

Why does it do that?

Thanks,

Tom
 
tshad said:
I have a listbox that I fill and can't select the 1st item until I select
another item first.

I tried to add the following to see what the behavior was:

SearchList.SelectedIndex = 2
trace.warn("at 1st SearchList test selectedIndex = " &
SearchList.SelectedIndex)
SearchList.SelectedIndex = -1
trace.warn("at 2nd SearchList test selectedIndex = " &
SearchList.SelectedIndex)

This came back with:

at 1st SearchList test selectedIndex = 2
at 2nd SearchList test selectedIndex = 0

After setting index to -1, it is always 0 (even though nothing is showing as
selected), so when you check it always acts as if the first one was
selected. This is a real problem.

Is there a way to set it as not selected and then how do you check if this
is the case?

Thanks,

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top