469,282 Members | 1,955 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

DropDownList

I've databound the dropdownlist. How do I prevent it from selecting the
first item in the list during page load.
Nov 16 '05 #1
7 4334
Mike D wrote:
I've databound the dropdownlist. How do I prevent it from selecting the
first item in the list during page load.

Can you manually set the SelectedIndex to -1?
It would work

Andrey
Nov 16 '05 #2
Mike,

An item is always selected in the dropdownlist control. You cannot deselect
every item in the list at the same time. You can change the selection of the
list though by specifing an index to select (e.g. DropDownList1.SelectedIndex
= 3;). If i have misunderstood your question please reply to this post.

I hope this helps.
Nov 16 '05 #3
If I did a Sql select, for example the alpabet, the first letter "A" is
displayed in the dropdownlist yet I haven't clicked on the dropdown to
select a letter yet. If the dropdown is null, then I could search the whole
alphabet. I want the dropdownlist to display nothing until I click the
dropdown and select a value.

"Brian Brown" <Br********@discussions.microsoft.com> wrote in message
news:E1**********************************@microsof t.com...
Mike,

An item is always selected in the dropdownlist control. You cannot
deselect
every item in the list at the same time. You can change the selection of
the
list though by specifing an index to select (e.g.
DropDownList1.SelectedIndex
= 3;). If i have misunderstood your question please reply to this post.

I hope this helps.

Nov 16 '05 #4
Mike,

I am not sure if I follow what you are saying. If there are no entries in
the dropdownlist the SelectedIndex will be equal to -1. So are you saying
that when the dropdownlist is in this state (SelectedIndex = -1 [no items in
the list]) and you click on the dropdownlist you want it to bind to the data
at that moment so you can make a selection?

If this is or is not correct please reply so I may understand more clearly
and try to help you.

Thanks.

Nov 16 '05 #5
Mike D wrote:
If I did a Sql select, for example the alpabet, the first letter "A" is
displayed in the dropdownlist yet I haven't clicked on the dropdown to
select a letter yet. If the dropdown is null, then I could search the whole
alphabet. I want the dropdownlist to display nothing until I click the
dropdown and select a value.

"Brian Brown" <Br********@discussions.microsoft.com> wrote in message
news:E1**********************************@microsof t.com...
Mike,

An item is always selected in the dropdownlist control. You cannot
deselect
every item in the list at the same time. You can change the selection of
the
list though by specifing an index to select (e.g.
DropDownList1.SelectedIndex
= 3;). If i have misunderstood your question please reply to this post.

I hope this helps.

Then you need to somehow add a blank as the first row in the binding dataset,
e.g if you use a query/view for dropdown box's data source, you can do like

select '' as your_column_name
UNION ALL SELECT whatever_you _select

This way you get a blank selected as the first row in the dadaset

Andrey
Nov 16 '05 #6
It's like Muzzy just suggested. I tried Muzzy's idea with the blank being
first and that will work. I'm used to Powerbuilder retrieving the
information but putting a null value in the dropdown until I click the
dropdown button and allowing me to select my options.

Thanks guys for all your help

"Brian Brown" <Br********@discussions.microsoft.com> wrote in message
news:83**********************************@microsof t.com...
Mike,

I am not sure if I follow what you are saying. If there are no entries in
the dropdownlist the SelectedIndex will be equal to -1. So are you saying
that when the dropdownlist is in this state (SelectedIndex = -1 [no items
in
the list]) and you click on the dropdownlist you want it to bind to the
data
at that moment so you can make a selection?

If this is or is not correct please reply so I may understand more clearly
and try to help you.

Thanks.

Nov 16 '05 #7
Mike D wrote:
It's like Muzzy just suggested. I tried Muzzy's idea with the blank being
first and that will work. I'm used to Powerbuilder retrieving the
information but putting a null value in the dropdown until I click the
dropdown button and allowing me to select my options.

Thanks guys for all your help
Any time ;)
"Brian Brown" <Br********@discussions.microsoft.com> wrote in message
news:83**********************************@microsof t.com...
Mike,

I am not sure if I follow what you are saying. If there are no entries in
the dropdownlist the SelectedIndex will be equal to -1. So are you saying
that when the dropdownlist is in this state (SelectedIndex = -1 [no items
in
the list]) and you click on the dropdownlist you want it to bind to the
data
at that moment so you can make a selection?

If this is or is not correct please reply so I may understand more clearly
and try to help you.

Thanks.


Nov 16 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Shiju Poyilil | last post: by
10 posts views Thread by Sacha Korell | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.