asp:listbox problem

Discussion in 'ASP .Net Web Controls' started by Samir Sanghani, Aug 5, 2003.

  1. 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
     
    Samir Sanghani, Aug 5, 2003
    #1
    1. Advertising

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

    Svetlin Grancharov
    >-----Original Message-----
    >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
    >
    >
    >.
    >
     
    Svetlin Grancharov, Aug 5, 2003
    #2
    1. Advertising

  3. 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

    "Svetlin Grancharov" <> wrote in message
    news:046701c35b9d$af2ef870$...
    > Hi Samir,
    > why don't you use values with these list items.
    > Check SelectedValue and SelectedItem properties.
    >
    > Svetlin Grancharov
    > >-----Original Message-----
    > >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
    > >
    > >
    > >.
    > >
     
    Samir Sanghani, Aug 7, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. blenderdude
    Replies:
    0
    Views:
    1,149
    blenderdude
    Aug 3, 2003
  2. DC Gringo
    Replies:
    0
    Views:
    421
    DC Gringo
    Apr 6, 2004
  3. kent
    Replies:
    1
    Views:
    909
    Andrew de la Harpe
    May 3, 2004
  4. Simon Prince
    Replies:
    2
    Views:
    3,384
    =?Utf-8?B?TWljaGFlbCBUYXlsb3I=?=
    Oct 19, 2004
  5. Chris Kettenbach

    Listbox selection to populate another listbox?

    Chris Kettenbach, Jun 15, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    1,687
    Chris Kettenbach
    Jun 16, 2005
Loading...

Share This Page