473,396 Members | 1,970 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 4491
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Stanley J Mroczek | last post by:
How do you load a dropdownlist when edit is clicked in a datagrid ? <Columns> <asp:BoundColumn DataField="OptionDescription" ItemStyle-Wrap="True" HeaderText="Option...
4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
2
by: Dominic | last post by:
Hi guys, I'm not sure if this question belongs to FAQ, but I couldn't find a concrete answer. I created a Datagrid control using ItemTemplate, but it's NOT a in-place editing datagrid. One of...
2
by: Shiju Poyilil | last post by:
Hello, I have a datagrid with only one row and its having 2 dropdownlists, I need to populate the secodn dropdownlist on the basis of the selection in the first dropdown. but I am not able to...
10
by: Sacha Korell | last post by:
I'm trying to load a drop-down list with all DropDownList control names from another page. How would I be able to find those DropDownList controls? The FindControl method will only find a...
15
by: glenn | last post by:
Hi folks, I have a DropDownList in a DataGrid that is populated from records in a database. I want to add a value that might be a string such as "Select a Company" for the first item since an...
1
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
1
by: Brett | last post by:
I have a DropDownList in an ASP.NET web form that is populated with items from a lookup table by binding that DropDownList to a SqlDataSource. However, the items in the lookup table can change over...
0
by: asmx126453 | last post by:
Hey mensen I am having some big troubles here i tryd solving it myself with internet for 2 days but i kind fix it. Its about this i have a DotNet project that alrydi is online and working for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.