Home All Groups Group Topic Archive Search About

add a list item to a bound control?

Author
14 Feb 2006 6:55 PM
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?

Author
14 Feb 2006 7:23 PM
Chris
jr***@blackstaronline.net wrote:
> 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
Author
14 Feb 2006 9:05 PM
jreid
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...",""))