Annoying drop down list...

P

Paul M

Hi folks,

When I set the datasource of a dropdown list and bind it, the drop down list
always defaults to the first item in the list. I need it to default to
Nothing or NULL or whatever it is now in .NET.

The situation I've got is a group of combo boxes that interelate. So if you
select item 1 from drop down A, you are prompted to select an item in drop
down B and if you select item 2 from drop down A you are prompted to select
an item from drop down C. At the moment my web page is putting a value in
all three drop downs, when it should only ever be two.

Thanks in advance...

Paul
 
M

Michael

After you call .DataBind on the dropdownlist, you can add the following to
add a blank item at the beginning, that will be selected

DropDownList1.Items.Insert(0, "")
DropDownList1.Items(0).Selected = True

--Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top