Why SelectedIndexChanged event for DropDownList sometimes did not fired or beware of the same values

Discussion in 'ASP .Net' started by hal, Sep 13, 2004.

  1. hal

    hal Guest

    I dont know if this helps anyone but i've just banged my head for the
    past two hours with the problem of a dropdownlist in asp.net which
    somwtimes did not fired or when it was auto posted back the value and
    text propertie of the control was always the value of the first
    listitem in the control althought i've selected entirely different
    item (before the autopost).

    After trying manual population of the dropdown control (without
    databinding), placing the breakpoints on every imaginable place on the
    page the answer was...well..simple.

    The matter is that i've populated dropdown with DIFFERENT TEXT
    properties but each text propertie had THE SAME value (eg. text
    property was John, value propertie vas ,text property was
    Mary, value propertie vas , etc... )

    And .net through its divine wisdom obviously always checks only VALUE
    propertie on postback (text AND value propertie should be a better
    choice or maybe not?) and because ALL values were the same (for
    testing reason) this little annoying behaviour occured.

    Have a nice day!
    Timothy
     
    hal, Sep 13, 2004
    #1
    1. Advertising

  2. Thanks Timothy, good to know that.

    Eliyahu

    "hal" <> wrote in message
    news:...
    > I dont know if this helps anyone but i've just banged my head for the
    > past two hours with the problem of a dropdownlist in asp.net which
    > somwtimes did not fired or when it was auto posted back the value and
    > text propertie of the control was always the value of the first
    > listitem in the control althought i've selected entirely different
    > item (before the autopost).
    >
    > After trying manual population of the dropdown control (without
    > databinding), placing the breakpoints on every imaginable place on the
    > page the answer was...well..simple.
    >
    > The matter is that i've populated dropdown with DIFFERENT TEXT
    > properties but each text propertie had THE SAME value (eg. text
    > property was John, value propertie vas ,text property was
    > Mary, value propertie vas , etc... )
    >
    > And .net through its divine wisdom obviously always checks only VALUE
    > propertie on postback (text AND value propertie should be a better
    > choice or maybe not?) and because ALL values were the same (for
    > testing reason) this little annoying behaviour occured.
    >
    > Have a nice day!
    > Timothy
     
    Eliyahu Goldin, Sep 13, 2004
    #2
    1. Advertising

  3. RE: Why SelectedIndexChanged event for DropDownList sometimes did not

    Although also checking the text of the submitted item could be helpful, it's
    also impossible. When a browser submits a form, it submits a set of
    (name,value) pairs for each enabled form element for which it has a value.
    So, all the server receives for your list is the name of the list (which
    asp.net associates with your control) and the "value" of the selected item.
    So, there's no way for asp.net to know which "" the user picked.
    Unless you've got something very specific in mind, using duplicate "value"
    properties for items in a list is a Bad Idea(tm).

    "hal" wrote:

    > I dont know if this helps anyone but i've just banged my head for the
    > past two hours with the problem of a dropdownlist in asp.net which
    > somwtimes did not fired or when it was auto posted back the value and
    > text propertie of the control was always the value of the first
    > listitem in the control althought i've selected entirely different
    > item (before the autopost).
    >
    > After trying manual population of the dropdown control (without
    > databinding), placing the breakpoints on every imaginable place on the
    > page the answer was...well..simple.
    >
    > The matter is that i've populated dropdown with DIFFERENT TEXT
    > properties but each text propertie had THE SAME value (eg. text
    > property was John, value propertie vas ,text property was
    > Mary, value propertie vas , etc... )
    >
    > And .net through its divine wisdom obviously always checks only VALUE
    > propertie on postback (text AND value propertie should be a better
    > choice or maybe not?) and because ALL values were the same (for
    > testing reason) this little annoying behaviour occured.
    >
    > Have a nice day!
    > Timothy
    >
     
    =?Utf-8?B?SmVyZW15IERhdmlz?=, Sep 13, 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. Lew Barnesson
    Replies:
    3
    Views:
    810
    Lew Barnesson
    Dec 4, 2004
  2. =?Utf-8?B?YWJvaXZpbg==?=

    DropDownList SelectedIndexChanged Event not fired

    =?Utf-8?B?YWJvaXZpbg==?=, Feb 9, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    380
    =?Utf-8?B?YWJvaXZpbg==?=
    Feb 9, 2005
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,032
    Smokey Grindel
    Dec 2, 2006
  4. BentleyInc

    SelectedIndexChanged event is not fired

    BentleyInc, Dec 10, 2004, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    188
    ComSpex
    Dec 17, 2004
  5. Jason
    Replies:
    0
    Views:
    391
    Jason
    Oct 4, 2006
Loading...

Share This Page