473,407 Members | 2,359 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,407 software developers and data experts.

DropDownList w/o default

Hi,

is it possible to leave a DropDownList's selection empty? Our application
requires for some ddl's that they are kept blank w/o an initial value so
that we can add a RequiredFieldValidator to them.

Regards,
Michael
Nov 19 '05 #1
11 2241
Generally this is done by adding an adtional entry with a text such as
"(Please select a value)"

Patrice

--

"Michael Groeger" <go*********@web.de> a écrit dans le message de
news:Oj**************@TK2MSFTNGP15.phx.gbl...
Hi,

is it possible to leave a DropDownList's selection empty? Our application
requires for some ddl's that they are kept blank w/o an initial value so
that we can add a RequiredFieldValidator to them.

Regards,
Michael

Nov 19 '05 #2
hi Michael
try to disable and enable ur validator in ur condation may be it work
"Michael Groeger" wrote:
Hi,

is it possible to leave a DropDownList's selection empty? Our application
requires for some ddl's that they are kept blank w/o an initial value so
that we can add a RequiredFieldValidator to them.

Regards,
Michael

Nov 19 '05 #3
Some people, including myself, prefer doing it on the bound datatable.

Eliyahu

"Patrice" <no****@nowhere.com> wrote in message
news:uE**************@TK2MSFTNGP14.phx.gbl...
Generally this is done by adding an adtional entry with a text such as
"(Please select a value)"

Patrice

--

"Michael Groeger" <go*********@web.de> a écrit dans le message de
news:Oj**************@TK2MSFTNGP15.phx.gbl...
Hi,

is it possible to leave a DropDownList's selection empty? Our application requires for some ddl's that they are kept blank w/o an initial value so
that we can add a RequiredFieldValidator to them.

Regards,
Michael


Nov 19 '05 #4
Patrice, Eliyahu,

thanks for your reply. I understand that I can solve it that way, but this
both would mean that "(Please select a value)" is at least a valid value for
the DropDownList. How would I get it work together with Field Validators (I
must admit that I am still new to ASP.NET and don't know much about working
with them)? What value should I define for the ListItem which states
"(Please select a value)"?

Eliyahu, mixing database design with application design, seems for me not to
be a good start. It is much easier to do so, but it would mean that values
which are only required to fix application issues are treated as valid
values in the database.

When trying to do the same for Windows Forms applications I do have
ComboBoxes (which seems to me the pendant to DropDownLists) where as default
no item is selected. This is much easier for us to work with.

Regards,
Michael

"Eliyahu Goldin" <re*************@monarchmed.com> schrieb im Newsbeitrag
news:Oa**************@TK2MSFTNGP12.phx.gbl...
Some people, including myself, prefer doing it on the bound datatable.

Eliyahu

"Patrice" <no****@nowhere.com> wrote in message
news:uE**************@TK2MSFTNGP14.phx.gbl...
Generally this is done by adding an adtional entry with a text such as
"(Please select a value)"

Patrice

--

"Michael Groeger" <go*********@web.de> a écrit dans le message de
news:Oj**************@TK2MSFTNGP15.phx.gbl...
Hi,

is it possible to leave a DropDownList's selection empty? Our application requires for some ddl's that they are kept blank w/o an initial value so that we can add a RequiredFieldValidator to them.

Regards,
Michael



Nov 19 '05 #5
> thanks for your reply. I understand that I can solve it that way, but this
both would mean that "(Please select a value)" is at least a valid value for the DropDownList. How would I get it work together with Field Validators (I must admit that I am still new to ASP.NET and don't know much about working with them)? What value should I define for the ListItem which states
"(Please select a value)"? Who forces you to use validators? I am not so new to ASP.NET already, but I
never used them anyway.
I would recommend using text "(Please select a value)" only if a value must
be selected and there is no default one. If there is a default, you should
set it selected straight away. If the selection is optional, you should make
original text empty.
You can use an empty string as a value, or whatever else that will tell the
application that no selection has been made.
Eliyahu, mixing database design with application design, seems for me not to be a good start. It is much easier to do so, but it would mean that values
which are only required to fix application issues are treated as valid
values in the database. No, I did not mean the table in the database. I mean the DataTable in the
Dataset the list is bound to. Or any other dotnet datasource for this
matter. And as far as database design is concern you are 100% right.
When trying to do the same for Windows Forms applications I do have
ComboBoxes (which seems to me the pendant to DropDownLists) where as default no item is selected. This is much easier for us to work with. Welcome to the web design world!

Regards,
Michael

"Eliyahu Goldin" <re*************@monarchmed.com> schrieb im Newsbeitrag
news:Oa**************@TK2MSFTNGP12.phx.gbl...
Some people, including myself, prefer doing it on the bound datatable.

Eliyahu

"Patrice" <no****@nowhere.com> wrote in message
news:uE**************@TK2MSFTNGP14.phx.gbl...
Generally this is done by adding an adtional entry with a text such as
"(Please select a value)"

Patrice

--

"Michael Groeger" <go*********@web.de> a écrit dans le message de
news:Oj**************@TK2MSFTNGP15.phx.gbl...
> Hi,
>
> is it possible to leave a DropDownList's selection empty? Our application
> requires for some ddl's that they are kept blank w/o an initial
value so > that we can add a RequiredFieldValidator to them.
>
> Regards,
> Michael
>
>



Nov 19 '05 #6
You can use a required field validator for this. Just set the initial
value property to whatever item is initially selected ("Select an Item"
or ""). This will force the user to make a selection other than the
initial value.

Nov 19 '05 #7
Eliyahu,

thanks for you follow-up.
Who forces you to use validators? I am not so new to ASP.NET already, but I never used them anyway.
Well, it is a easy way to validate user input client-sided. Maybe there are
better ways, which I don't know yet. Let me know ;)
I would recommend using text "(Please select a value)" only if a value must be selected and there is no default one. If there is a default, you should
set it selected straight away. If the selection is optional, you should make original text empty.
I agree that if defaults exist, we should set them straight away. What I am
concerning about are only required fields w/o defaults.
Well, you just revealed a lack of design in my application. Cause right now
when editing values with optional fields, it is not possible for users to
make selections empty ;). Thanks for that!
You can use an empty string as a value, or whatever else that will tell the application that no selection has been made.
Hmm, empty string seems to be a good point to start ;)
Eliyahu, mixing database design with application design, seems for me not to
be a good start. It is much easier to do so, but it would mean that

values which are only required to fix application issues are treated as valid
values in the database.

No, I did not mean the table in the database. I mean the DataTable in the
Dataset the list is bound to. Or any other dotnet datasource for this
matter. And as far as database design is concern you are 100% right.


Ok, I think I misunderstood you in your prior posting.
When trying to do the same for Windows Forms applications I do have
ComboBoxes (which seems to me the pendant to DropDownLists) where as

default
no item is selected. This is much easier for us to work with.

Welcome to the web design world!


Thank you ;)

Regards,
Michael
Nov 19 '05 #8


Hi you can achieve this functionality by adding the following code in
your codebehind

Dropdown1.Items.Insert(0, "----Select an Item----")
Dropdown1.SelectedIndex = 0
Dropdown1.SelectedItem.Value = ""
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #9
hi,

You can achieve this functionality by adding the following code in your
codebehind----

-----------------------------------------------------
Dropdown1.Items.Insert(0, "----Select an Item----")
Dropdown1.SelectedIndex = 0
Dropdown1.SelectedItem.Value = ""
-----------------------------------------------------
Narendra

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #10
You can acieve this functionality by adding the following code in your
codebehind area
Dropdown1.Items.Insert(0, "----Select an Item----")
Dropdown1.SelectedIndex = 0
Dropdown1.SelectedItem.Value = ""
Narendra

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #11
Hi Narendra,

thanks, I already solved it a similar way.

Regards,
Michael

"Narendra Yadav" <nm*@indiatimes.com> schrieb im Newsbeitrag
news:#X*************@TK2MSFTNGP09.phx.gbl...
You can acieve this functionality by adding the following code in your
codebehind area
Dropdown1.Items.Insert(0, "----Select an Item----")
Dropdown1.SelectedIndex = 0
Dropdown1.SelectedItem.Value = ""
Narendra

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

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...
0
by: adam | last post by:
i have custom user control and i'm trying to pass values to custom user control......I need help it seems to me i cannot pass the value to user control from dropdownlist. I have property in a...
7
by: Lastie | last post by:
Hi all, I’ve got a ‘dropdownlist’ web control and I can add ‘listitem’ no problem. I can also bind data from an SQL database fine. My problem is that I want to do both at the same...
2
by: huzz | last post by:
How do i make a dropdownlist selected value based on the value i retrive from the database. Basically i have an edit page and like to display the default value in a dropdown list from the...
1
by: Frank | last post by:
Hello, I have some text boxes and 2 drop down lists (DDL) within a panel like so: Everything updates fine but the values from the DDLs are always the items selected by default. In other words,...
1
by: IMB | last post by:
I'm using VS2005 and am working with a ASP.NET 2.0 web site and I'm coding in VB.NET. I understand that I can add an item to a databound dropdownlist and make it the default selection using the...
1
by: Vagabond Software | last post by:
I'm using a DropDownList in an EditItemTemplate column. This DropDownList will only ever have two dates in it; Now and the default DateTime value (1/1/1900 12:00:00 AM). Somewhere, somehow, the...
4
by: rn5a | last post by:
I am binding a DropDownList with records existing in a database table. I want to add an extra item *SELECT COMPANY* at index 0 so that by default, it gets selected. This is how I tried it but the...
2
by: Aswanth | last post by:
Hi.. I'm using Asp.Net with C#.... I'm having One Dropdownlist control(Users_Details_DDL) in Default.aspx Page... i'm having one Stored Procedure (Get_User_Email) which will display the Data...
3
by: =?Utf-8?B?Y21lZWsxXzE5OTk=?= | last post by:
Hello, On a webpage, create an UpdatePanel with two DropDownLists. Set AutoPostBack of DropDownList1 to true. In the SelectedIndexChanged method, refill DropDownList2 and set the focus to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.