You are going to need to populate either a Datatable or a dataset to bind data, you cant just stream data into a dropdownbox, not in the way your asking anyway.
Also, as a side bar, when people straight up ask for code samples that is normally when I don't provide any and I don't mean to sound rude or anything but this tells me that the person asking for code is looking for a "quick fix" right now and would rather not take the time to research the problem and that bothers me; you are a programmer, programmer's solve problems, that is why we do what we do.
Back to your question. The ddl has 3 parameters that you can set, a Datasource, DataValueField, and DataTextField the latter 2 params refer to fields in the datasource.
Your datasource can be anything but for this example i will use a datatable. In your code behind page you need to declare your datatable as Public and then when you need the dropdown populated call your method to connect to the database, populate your datatable and viola, you have data in your ddl.
Like i said, DataValueField and DataTextField need to refer to columns in your data source so say i query SQL and return the columns ID and Name to a datatable, Datatable is my source, DataValueField = ID and DataTextField = Name.
Hope this helps.
"The one language all programmers understand is profanity."
|