473,385 Members | 1,912 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,385 software developers and data experts.

how to set default value in dropdown list

109 100+
Hi all,

I have couple drop down list in my web forms.
All of them are bounded by database table.

so, what happens is even if user doesn't select anything from a drop down list it autometically insert the first value into database.

so, i like to insert at first position of drop downlist like, select one ?

Is there a way to do this in asp.net drop down which is bind by database table?

Thank You,
Dec 4 '07 #1
7 2767
Plater
7,872 Expert 4TB
The dropdownlist is going to be bound to whatever data that you bound to it.
You could either make the first entry in the bound data be "empty" of some sort.
Or unbind the dropdown and assign a value to the SelectedValue proeprty.

Actually you might be able to do that to a bound dropdownlist as well.
Dec 4 '07 #2
arial
109 100+
Can you explain in little bit more.

I understand the first value being empty. but I did not get you second comment bound to actual database?

Thank You,
Dec 4 '07 #3
Plater
7,872 Expert 4TB
You had said your dropdownlists are bound to a datatable.

Is it bound to a table that JUST contains values FOR the dropdown list, or is it bound to an overall table, and will therefor just display values from the column it is bound to, with the selected one being the value from the current row?
Dec 4 '07 #4
arial
109 100+
Also, anotherthing I am trying to do is.

I have datapicker control on my web form for user to select the date.

Now, when user click on edit, I need to put the date into that datepicker field based on value from database date field.

How can I do this?

I tried:

Datercv.SelectedDate = Datercv.SelectedDate(dsgingupdate1.Tables[0].Rows["DATE_RCV"].ToString());

but, its not working.

Thank You,
Dec 4 '07 #5
arial
109 100+
My dropdown list is bouned to the table that contains the value for the dropdownlist and my table does not have value like "select one".

Thank You,
Dec 4 '07 #6
Plater
7,872 Expert 4TB
Then after you call the databind function for the dropdown lists, set the selectedindex to the desired index? (It could be selectedItem and not SelectedIndex)
Dec 4 '07 #7
arial
109 100+
Thank You.

This problem is resolved now.
Dec 5 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Kerri | last post by:
Hi, I have an aspx page with a drop down. This is a page where a user can edit their user profile. When they go to this page, I want the dropdownlists to default to what it is in teh user...
7
by: NCrum | last post by:
I want to set the Default value of a Combobox for any changeable record and have got this working but it is totaly unsatisfactory see the code below I loop through the items in the Combo looking...
5
by: Kris Rockwell | last post by:
Hello (again), I have gotten the dropdown list functionality to work through a few tricks (probably not the most efficient, but it works) but I am not sure how to set the default selected value....
1
by: Kenneth Keeley | last post by:
Hi, Is it possible to have a dropdown list that when the page is first visited has a selected value of something like "Choose an Option". After the user has selected an option the the user should...
2
by: Eduardo78 | last post by:
I would like to set the default value of a combobox to "nothing" or spaces when my form loads. I am using the dropdown list property becasue i want the end-user to select only values listed in the...
1
by: Ben | last post by:
I have a formview with a few dropdownlists (software version, database version, etc). When a software version is selected, the database version dropdownlist updates itself accordingly. When in...
3
by: Steve | last post by:
I have a databound dropdown in my page. I want to make one of the values the default value. Any ideas? Just to explain further, I have also appended one item to the dropdown, using the...
2
by: rn5a | last post by:
During registration, users have to provide their date of birth. For the date & month part, there are 2 dropdown lists & for the year, there's a textbox. These 3 fields are finally merged together...
2
by: dhoward | last post by:
How do you default a dropdown list when a particular item is selected? I have a two drop down lists, one for state and one for county. If the user chooses a state outside of Alabama, I need the...
2
beacon
by: beacon | last post by:
I have a DAP that I've added a command button to (and by default is set to be coded using vbscript, but I'll use whatever works). The command button uses the onclick method to look at a dropdown...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.