add a list item to a bound control?

  • Thread starter Thread starter jreid
  • Start date Start date
J

jreid

Hi,

I have a drop down list thats bound to a SQL query. But I want to have
the top item or .SelectedItem to be a generic "Please Select..." with
no value. I've searched for the answer and tried every combination and
can't find an answer.

I've tried adding <ASP:ListItem> to the control but the bound data
overides it.

I'm using .NET with VB, Any suggestions?
 
Hi,

I have a drop down list thats bound to a SQL query. But I want to have
the top item or .SelectedItem to be a generic "Please Select..." with
no value. I've searched for the answer and tried every combination and
can't find an answer.

I've tried adding <ASP:ListItem> to the control but the bound data
overides it.

I'm using .NET with VB, Any suggestions?

Don't bind the object to the SQL. Just loop through the sql and add the
items in yourself. That way you'll can add your item at the top.

Chris
 
Thanks Chris,

Actually I figured it out and it seems for this instance a little
easier than looping through the results. All I had to do was add this
one line after I bound the data to the control.

mydropdown.Items.Insert(0,New ListItem("Please Select...",""))
 
Back
Top