I am trying to populate a dropdown using values from a column. Now the problem is: I am not getting the actual values (the country codes like India(+61)) in the dropdown. In
You haven't set the DataTextField
in the DropDownList
. It's recommended to set also the DataValueField
In your aspx add the DataTextField
property:
You can also set it in the code behind, like the other answers show.
Otherwise the behaviour that you are seeing, is because the DataBound is calling the ToString()
to display the info, as you don't provided wich data field look for.