Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert "Select From Dropdownlist" at top of dropdownlist 1

Status
Not open for further replies.

bubberz

Programmer
Dec 23, 2004
117
US
If I have a dropdownlist, and I want to have the first item that shows which says "Select from this list", how do I do that.
So, if I only have one DB row returned, the ddl will have two records:
1. "Select from this list"
2. The DB record

I've done it before, but can't remember.

Thanks!
 
ddl.Items.Insert(0, "Select from this list")

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
checkai,

I put this in Page_load:
Page_Load

....code
If myRDR.HasRows = True Then
ddlGroup2.Items.Insert(0, "Select from this list")
ddlGroup2.DataSource = myRDR
ddlGroup2.DataTextField = "Expr2"
ddlGroup2.DataValueField = "GroupDescription"
ddlGroup2.DataBind()
End If
Con1.Close()

Else
ddlGroup2.Items.Insert(0, "Select from this list")
End Sub

.....and in the ddl_load, but can't get it to work:
Private Sub ddlGroup2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlGroup2.Load
ddlGroup2.Items.Insert(0, "Select from this list")
End Sub
 
you need to put the insert after the databind...

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
THANK YOU CHECKAI!

That solves my whole problem with these three dropdownlists being populated. I just have to figure out the third one, but I think now I'm 90% of the way there.
Thanks a ton!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top