ListBox SelectedIndex is always -1

Discussion in 'ASP .Net' started by S. Justin Gengo, Feb 17, 2004.

  1. HB,

    You're probably databinding the list box on every page load which is
    resetting it before you can get the selected value.

    Put:

    If Not IsPostBack Then
    '---Datbind list box here
    End If

    Into your code and you'll get the selected value.

    --
    Sincerely,

    S. Justin Gengo, MCP
    Web Developer / Programmer

    Free code library at:
    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzche


    "HB" <> wrote in message
    news:O$...
    > Guys,
    >
    > PLS tell my why the ListBox SelectedIndex is always -1?, I am sure

    selection
    > was made.
    >
    > Thanks
    >
    > HB
    >
    >
    S. Justin Gengo, Feb 17, 2004
    #1
    1. Advertising

  2. S. Justin Gengo

    HB Guest

    Guys,

    PLS tell my why the ListBox SelectedIndex is always -1?, I am sure selection
    was made.

    Thanks

    HB
    HB, Feb 17, 2004
    #2
    1. Advertising

  3. S. Justin Gengo

    HB Guest

    Many Thanks

    "S. Justin Gengo" <> wrote in message
    news:u%23%...
    > HB,
    >
    > You're probably databinding the list box on every page load which is
    > resetting it before you can get the selected value.
    >
    > Put:
    >
    > If Not IsPostBack Then
    > '---Datbind list box here
    > End If
    >
    > Into your code and you'll get the selected value.
    >
    > --
    > Sincerely,
    >
    > S. Justin Gengo, MCP
    > Web Developer / Programmer
    >
    > Free code library at:
    > www.aboutfortunate.com
    >
    > "Out of chaos comes order."
    > Nietzche
    >
    >
    > "HB" <> wrote in message
    > news:O$...
    > > Guys,
    > >
    > > PLS tell my why the ListBox SelectedIndex is always -1?, I am sure

    > selection
    > > was made.
    > >
    > > Thanks
    > >
    > > HB
    > >
    > >

    >
    >
    HB, Feb 17, 2004
    #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. John Giblin

    Asp:ListBox and selectedindex

    John Giblin, Nov 26, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    1,105
    John Giblin
    Nov 26, 2003
  2. =?Utf-8?B?TGll?=
    Replies:
    5
    Views:
    675
    =?Utf-8?B?TGll?=
    Dec 14, 2004
  3. =?Utf-8?B?Q2FybG8gTWFyY2hlc29uaQ==?=

    ListBox not returning correct SelectedIndex

    =?Utf-8?B?Q2FybG8gTWFyY2hlc29uaQ==?=, Feb 4, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    4,272
    Karl Seguin
    Feb 4, 2005
  4. js
    Replies:
    0
    Views:
    551
  5. b_gul_t

    ListBox SelectedIndex is always -1

    b_gul_t, Mar 5, 2005, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    251
    b_gul_t
    Mar 7, 2005
Loading...

Share This Page