473,503 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Selecting an item in a drop down list

How do you force a drop down list to default to a particular item based on
its value?

I have a drop down list with options Yes, No, Maybe, All, and I would like
it to default to "All"

This is my code, what am I doing wrong?
ddlBilling.SelectedIndex =
ddlBilling.Items.IndexOf(ddlBilling.Items.FindByVa lue("All"))
Apr 10 '06 #1
3 1777
ddl.ClearSelection() // in case something else is selected
ddl.Items.FindByValue("All").Selected = true

-Brock
http://staff.develop.com/ballen

How do you force a drop down list to default to a particular item
based on its value?

I have a drop down list with options Yes, No, Maybe, All, and I would
like it to default to "All"

This is my code, what am I doing wrong?
ddlBilling.SelectedIndex =
ddlBilling.Items.IndexOf(ddlBilling.Items.FindByVa lue("All"))

Apr 10 '06 #2
That looks fine...is that the value of the dropdown or the text?

if it's the text, you need to use FindByText

Otherwise, where is this code?are you binding before?

Karl

--
http://www.openmymind.net/

"KatMagic" <SS********@yahoo.com> wrote in message
news:ue**************@TK2MSFTNGP05.phx.gbl...
How do you force a drop down list to default to a particular item based on
its value?

I have a drop down list with options Yes, No, Maybe, All, and I would like
it to default to "All"

This is my code, what am I doing wrong?
ddlBilling.SelectedIndex =
ddlBilling.Items.IndexOf(ddlBilling.Items.FindByVa lue("All"))

Apr 10 '06 #3
Thanks everyone you were very helpful. As you suggested, I was incorrectly
attempting to select by value, when "All" was a text value. Clearing the
selection and selecting by the actual value (0), worked! Thanks.

"KatMagic" <SS********@yahoo.com> wrote in message
news:ue**************@TK2MSFTNGP05.phx.gbl...
How do you force a drop down list to default to a particular item based on
its value?

I have a drop down list with options Yes, No, Maybe, All, and I would like
it to default to "All"

This is my code, what am I doing wrong?
ddlBilling.SelectedIndex =
ddlBilling.Items.IndexOf(ddlBilling.Items.FindByVa lue("All"))

Apr 11 '06 #4

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

Similar topics

2
376
by: Bogdan Zamfir | last post by:
Hi, I have a page called MyTargetPage.aspx with a drop down list. When I pass control to that page, I send an ID in querystring, like this Server.transfer("MyTargetPage.aspx?PrjID=" &...
3
1781
by: Novice Computer User | last post by:
I have a drop down menu where people are able to select 1 item. However, I want to modify the drop down list so that the person can select more than 1 item (i.e by holding down the shift button...
3
2981
by: John Walker | last post by:
Hi, On an ASP.NET page I have a drop down list control. When the user pulls down the list and makes a selection, I perform validation, and if the validation fails I want the selected item in...
6
3123
by: Mike Wilson | last post by:
Dear Group, I have a heirarchical set of database tables, say - "order" and "order_type" and want to display a series of orders in a grid control, and in place of the order_type foreign key...
2
1341
by: yogeshtiwarijbp | last post by:
when i select data from the drop down list box and display data in the datagrid the first data in the dropdownlistbox not shown the requireddata in the grid. i have used 2 tables and after selecting...
3
2155
by: SQLjunky | last post by:
Hello, Contrary to what my screen name indicates, i'm actually quite new to SQL. Having said that, I'll get right into my problem. I'm trying to query an mssql database to return to the value...
2
1687
by: SunnySnow29 | last post by:
Hi, I have a 2 drop down lists in C# populated with data from a SQL 2005 db. When a new item of data is inserted the second list must update to reflect the change (the first drop down list will...
3
1224
by: mark.norgate | last post by:
Hi Another problem... My drop down is always defaulting to selecting the first item in the drop down, even though I've got code specifically to change it to a different item: Dim adapter...
1
2342
by: bytenut | last post by:
I would like to display two field values in a combo after selecting from the list items... i.e. my drop-down shows two fields from a lookup, but when I select the item, only the first field value is...
0
7202
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
7280
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
7330
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...
1
6991
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
5578
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
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.