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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dropdownlist control

Status
Not open for further replies.

ami7

Programmer
Oct 3, 2002
48
GB
hi,

Can anyone tell me how to populate a dropdownlist control in .aspx page with the values of a single column from a table.

thanks,
ami.
 
What do you mean by 'a single column'?
Do you just want to fill the 'Text' property and leave the 'Value' empty?

If you only have one column on the database, you can link both the 'Text' and 'Value' to that column:
Combo1.DataSource = MyDt
Combo1.DataTextField = "MyCol1"
Combo1.DataValueField = "MyCol1"
Combo1.DataBind()

If you really want to leave the value empty, try adding an empty dumb column to your SQL:
"SELECT '' AS ColEmpty, MyCol1 FROM MyTable"
Then link it like this:
Combo1.DataSource = MyDt
Combo1.DataTextField = "MyCol1"
Combo1.DataValueField = "ColEmpty"
Combo1.DataBind()

Hope this helps, but if this is not what you were looking for, please explain it better.
NetAngel
 
Thanks for your reply.
My query was to populate a dropdownlist control with data from database.
Basically i wanted to populate that field with one table column.
anyways the problem is resolved now.

Thanks again,
ami.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top