I want to populate a dropdownlist with comma seperated values from a textbox. I have below code:
sDDvalues = txtValues.Text
Me.DropDownList1.Items.Clear()
Dim months() As String = {sDDvalues}
Me.DropDownList1.DataSource = months
Me.DropDownList1.DataBind()
I have entered in the textbox like: value1, value2 and “value1”, “value2” and ‘value1′,’value2’, but every combination is returned as 1 option:
<option value="'value1', 'value2'">'value1', 'value2'</option>
Entering the actual values for months() like: {“value1”, “value2”} returns a correct dropdown:
<option value="value1">value1</option>
<option value="value2">value2</option>
Does anyone know how to solve this, so it populates from the values in the textbox?
Thanks in advance!
Marcellino
It should be:
So completed:
Input in the textbox would be like:
value1 value2 value3If you wanted to have it split at a comma then use:
Input in the textbox would be like: this is my value1, this is my value2, this is my value3
Thanks for the responses!