First Item in DropDownList does not fire OnSelectedIndexChanged

Discussion in 'ASP .Net' started by =?Utf-8?B?Z2xlbm4=?=, Apr 25, 2006.

  1. Hi folks,

    If I want to select the first item in a DropDownList, I need to first select
    any item other than the first item and then next I select the first item
    which will then fire an event saying that I clicked the first item.

    Why can't I just select the first item to get an event to fire without
    having to first select any other item.

    Thanks for any tips.
    glenn
    =?Utf-8?B?Z2xlbm4=?=, Apr 25, 2006
    #1
    1. Advertising

  2. =?Utf-8?B?Z2xlbm4=?=

    Norman Yuan Guest

    Well, if the first item is already displayed in the dropdown list, you, of
    course can still click the dropdown to pop up the list and reselect the
    first item. However, the SelectedIndex remains unchanged, therefore not
    SelectedIndexChanged (notice the event name) event fires. If you have to do
    something even the SelectedIndex is not changed, you have to design your own
    way to triger the posting back and get the dropdown's SelectedIndex value on
    the server and do something accordingly.

    "glenn" <> wrote in message
    news:...
    > Hi folks,
    >
    > If I want to select the first item in a DropDownList, I need to first
    > select
    > any item other than the first item and then next I select the first item
    > which will then fire an event saying that I clicked the first item.
    >
    > Why can't I just select the first item to get an event to fire without
    > having to first select any other item.
    >
    > Thanks for any tips.
    > glenn
    Norman Yuan, Apr 25, 2006
    #2
    1. Advertising

  3. Re: First Item in DropDownList does not fire OnSelectedIndexChange

    For example you could add an extra blank or dummy item to your list and have
    that be the defulat slected item. That way as soo as a user selects a valid
    item it will always have changed from the original item.

    "Norman Yuan" wrote:

    > Well, if the first item is already displayed in the dropdown list, you, of
    > course can still click the dropdown to pop up the list and reselect the
    > first item. However, the SelectedIndex remains unchanged, therefore not
    > SelectedIndexChanged (notice the event name) event fires. If you have to do
    > something even the SelectedIndex is not changed, you have to design your own
    > way to triger the posting back and get the dropdown's SelectedIndex value on
    > the server and do something accordingly.
    >
    > "glenn" <> wrote in message
    > news:...
    > > Hi folks,
    > >
    > > If I want to select the first item in a DropDownList, I need to first
    > > select
    > > any item other than the first item and then next I select the first item
    > > which will then fire an event saying that I clicked the first item.
    > >
    > > Why can't I just select the first item to get an event to fire without
    > > having to first select any other item.
    > >
    > > Thanks for any tips.
    > > glenn

    >
    >
    >
    =?Utf-8?B?Y2xpY2tvbg==?=, Apr 25, 2006
    #3
  4. Re: First Item in DropDownList does not fire OnSelectedIndexChange

    How could I add this dummy item to a ddl that has already been populated with
    records from my db?

    thanks,
    glenn

    "clickon" wrote:

    > For example you could add an extra blank or dummy item to your list and have
    > that be the defulat slected item. That way as soo as a user selects a valid
    > item it will always have changed from the original item.
    >
    > "Norman Yuan" wrote:
    >
    > > Well, if the first item is already displayed in the dropdown list, you, of
    > > course can still click the dropdown to pop up the list and reselect the
    > > first item. However, the SelectedIndex remains unchanged, therefore not
    > > SelectedIndexChanged (notice the event name) event fires. If you have to do
    > > something even the SelectedIndex is not changed, you have to design your own
    > > way to triger the posting back and get the dropdown's SelectedIndex value on
    > > the server and do something accordingly.
    > >
    > > "glenn" <> wrote in message
    > > news:...
    > > > Hi folks,
    > > >
    > > > If I want to select the first item in a DropDownList, I need to first
    > > > select
    > > > any item other than the first item and then next I select the first item
    > > > which will then fire an event saying that I clicked the first item.
    > > >
    > > > Why can't I just select the first item to get an event to fire without
    > > > having to first select any other item.
    > > >
    > > > Thanks for any tips.
    > > > glenn

    > >
    > >
    > >
    =?Utf-8?B?Z2xlbm4=?=, Apr 25, 2006
    #4
  5. =?Utf-8?B?Z2xlbm4=?=

    Justin Guest

    Re: First Item in DropDownList does not fire OnSelectedIndexChange

    dropdownlist.insert.Items.Insert(0, String.Empty)


    "glenn" <> wrote in message
    news:...
    > How could I add this dummy item to a ddl that has already been populated
    > with
    > records from my db?
    >
    > thanks,
    > glenn
    >
    > "clickon" wrote:
    >
    >> For example you could add an extra blank or dummy item to your list and
    >> have
    >> that be the defulat slected item. That way as soo as a user selects a
    >> valid
    >> item it will always have changed from the original item.
    >>
    >> "Norman Yuan" wrote:
    >>
    >> > Well, if the first item is already displayed in the dropdown list, you,
    >> > of
    >> > course can still click the dropdown to pop up the list and reselect the
    >> > first item. However, the SelectedIndex remains unchanged, therefore not
    >> > SelectedIndexChanged (notice the event name) event fires. If you have
    >> > to do
    >> > something even the SelectedIndex is not changed, you have to design
    >> > your own
    >> > way to triger the posting back and get the dropdown's SelectedIndex
    >> > value on
    >> > the server and do something accordingly.
    >> >
    >> > "glenn" <> wrote in message
    >> > news:...
    >> > > Hi folks,
    >> > >
    >> > > If I want to select the first item in a DropDownList, I need to first
    >> > > select
    >> > > any item other than the first item and then next I select the first
    >> > > item
    >> > > which will then fire an event saying that I clicked the first item.
    >> > >
    >> > > Why can't I just select the first item to get an event to fire
    >> > > without
    >> > > having to first select any other item.
    >> > >
    >> > > Thanks for any tips.
    >> > > glenn
    >> >
    >> >
    >> >
    Justin, Apr 25, 2006
    #5
  6. =?Utf-8?B?Z2xlbm4=?=

    Jeff Dillon Guest

    Re: First Item in DropDownList does not fire OnSelectedIndexChange

    SELECT "Add a company", -1
    UNION ALL
    SELECT CompanyName, CompanyID From Companies

    "Justin" <> wrote in message
    news:...
    > dropdownlist.insert.Items.Insert(0, String.Empty)
    >
    >
    > "glenn" <> wrote in message
    > news:...
    >> How could I add this dummy item to a ddl that has already been populated
    >> with
    >> records from my db?
    >>
    >> thanks,
    >> glenn
    >>
    >> "clickon" wrote:
    >>
    >>> For example you could add an extra blank or dummy item to your list and
    >>> have
    >>> that be the defulat slected item. That way as soo as a user selects a
    >>> valid
    >>> item it will always have changed from the original item.
    >>>
    >>> "Norman Yuan" wrote:
    >>>
    >>> > Well, if the first item is already displayed in the dropdown list,
    >>> > you, of
    >>> > course can still click the dropdown to pop up the list and reselect
    >>> > the
    >>> > first item. However, the SelectedIndex remains unchanged, therefore
    >>> > not
    >>> > SelectedIndexChanged (notice the event name) event fires. If you have
    >>> > to do
    >>> > something even the SelectedIndex is not changed, you have to design
    >>> > your own
    >>> > way to triger the posting back and get the dropdown's SelectedIndex
    >>> > value on
    >>> > the server and do something accordingly.
    >>> >
    >>> > "glenn" <> wrote in message
    >>> > news:...
    >>> > > Hi folks,
    >>> > >
    >>> > > If I want to select the first item in a DropDownList, I need to
    >>> > > first
    >>> > > select
    >>> > > any item other than the first item and then next I select the first
    >>> > > item
    >>> > > which will then fire an event saying that I clicked the first item.
    >>> > >
    >>> > > Why can't I just select the first item to get an event to fire
    >>> > > without
    >>> > > having to first select any other item.
    >>> > >
    >>> > > Thanks for any tips.
    >>> > > glenn
    >>> >
    >>> >
    >>> >

    >
    >
    Jeff Dillon, Apr 25, 2006
    #6
    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. Alexander Reichman

    Dropdownlist onselectedIndexChanged event not fires

    Alexander Reichman, Oct 17, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    23,287
  2. Stuart Allen
    Replies:
    0
    Views:
    412
    Stuart Allen
    Jan 18, 2005
  3. Replies:
    6
    Views:
    3,318
    Matt Berther
    Jan 19, 2005
  4. Paul L
    Replies:
    1
    Views:
    7,275
  5. Jerry

    DropDownList - onSelectedIndexChanged not firing

    Jerry, Apr 15, 2004, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    179
    Jerry Higgins
    Apr 16, 2004
Loading...

Share This Page