asp:listbox problem

S

Samir Sanghani

Hi All,

Am facing a problem with listbox control in asp.net. If the listbox has
entries which are duplicate in text value, selection of an entry down the
list causes the selectedindex property to return the least index containing
the same text even though that is not selected.

To elaborate:

if my list box contains elements in following sequence
a
b
c
a
d

on selection of the 2nd "a" the selectedindex contains value 0 instead of 3.

Has anyone faced this problem earlier? Is there any setting I could be
missing?

Thanks in advance for any help offered. A quick reply would be really
appreciated as this is causing a stand still in development.

Regards
Samir
 
S

Svetlin Grancharov

Hi Samir,
why don't you use values with these list items.
Check SelectedValue and SelectedItem properties.

Svetlin Grancharov
 
S

Samir Sanghani

Thanks Svetlin,

That option worked. I checked and found am not assigning any data in value
for the items. Assigning unique values there corrected the problem.

Thanks once again.
Samir
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top