Populating Drop-Down Control
Posted on 2003-11-15
I have a table with two columns which I would like to drive a drop-down control. I would like the DataTextField to be the values of the two columns concatenated together with some punctuation added, and the DataValueField to be the value of the second column only.
Data: Column 1: "Attendee"
Column 2: "150"
In the Drop-Down: DataTextField: "Attendee ($150)"
I can't seem to concatenate the columns together, either in the SQL statement itself, or by going through the data in a datareader and formatting the entries into the drop-down.
I have seen some VB samples like this:
Loop through a datareader and for each row:
droplist.Items.Add(New ListItem("textfield", "valuefield"))
but I can't get anything like this to work in C#.
Thanks for the help.