How do you add text and Value to a dropdown programatically?
Right now I use the binding method with no problems.
VB Code:
DropDownList1.DataTextField = "Name" DropDownList1.DataValueField = "CustomerID" DropDownList1.DataSource = SQLQuery() DropDownList1.DataBind()
However I have a need to do it manually on some of my dropdown web controls.
I can add items into the collection but the TEXT and VALUE are both the same when it should have been (ex Finance, 001).
VB Code:
With DropDownList2 .Items.Add("Finance") .Items.Add("Design") .Items.Add("Management") End With
**** DATA ****
Dept Code
------- ------
FINANCE 001
DESIGN 002
MANAGEMENT 003
TIF




Reply With Quote