By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,191 Members | 1,411 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,191 IT Pros & Developers. It's quick & easy.

First Item in DropDownList does not fire OnSelectedIndexChanged

P: n/a
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
Apr 25 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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" <gl***@discussions.microsoft.com> wrote in message
news:FE**********************************@microsof t.com...
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

Apr 25 '06 #2

P: n/a
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" <gl***@discussions.microsoft.com> wrote in message
news:FE**********************************@microsof t.com...
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


Apr 25 '06 #3

P: n/a
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" <gl***@discussions.microsoft.com> wrote in message
news:FE**********************************@microsof t.com...
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


Apr 25 '06 #4

P: n/a
dropdownlist.insert.Items.Insert(0, String.Empty)
"glenn" <gl***@discussions.microsoft.com> wrote in message
news:EA**********************************@microsof t.com...
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" <gl***@discussions.microsoft.com> wrote in message
> news:FE**********************************@microsof t.com...
> > 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
>
>
>

Apr 25 '06 #5

P: n/a
SELECT "Add a company", -1
UNION ALL
SELECT CompanyName, CompanyID From Companies

"Justin" <ju****@hotmail.com> wrote in message
news:Oh*************@TK2MSFTNGP05.phx.gbl...
dropdownlist.insert.Items.Insert(0, String.Empty)
"glenn" <gl***@discussions.microsoft.com> wrote in message
news:EA**********************************@microsof t.com...
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" <gl***@discussions.microsoft.com> wrote in message
> news:FE**********************************@microsof t.com...
> > 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
>
>
>


Apr 25 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.