We have an ASP.Net / VB.Net web form containing a drop down list in the markup of the aspx file. There is also a DataSet created with the DataSet designer.
We would like to populate the drop down with data from the DataSet.
Can you show me some sample markup and / or VB.Net coding that is required to populate the drop down list with the DataSet data?
Code-behind:
VB.Net:
And you see the "DataTextField" and "DataValueField" in the markup? There's where you put the name of fields you want to use as id (data value) and to display (data text) in the drop-down list.
Here's an example:
Markup
Code behind
ComboboxName.DataSource =YourDataSetName
ComboboxName.DataValueField =Name OF the field that you want to return its selected value
for example "ID"
ComboboxName.DataTextField =Name OF the field that you want to view in the drop down list
for example "Name"
ComboboxName.DataBind()