I have a static multiselect list-box tbl1 which contains values.
i m selecting several values i.e value1 and value2 and after clicking a button i want based on these selected values to create Dynamically (2) drop down boxes and append to them the values of my previous selection.
So for example if on my listbox select 1 and 2 i want to create 2 dropdowns and each of them contain values 1 and 2 accordingly.
I use the following code which assumes that tbl1 is a listbox on my form:
Dim drpbox As DropDownList
If tbl1.SelectedIndex > -1 Then
For ctr = 0 To tbl1.Items.Count() - 1
If tbl1.Items(ctr).Selected Then
drpbox = New DropDownList
drpbox.ID = "DrpBoxTbl" & ctr
drpbox.SelectedIndex = -1
drpbox.Items.Add(tbl1.SelectedItem)
plhProductFields.Controls.Add(drpbox)
End If
Next
This results the following HTML:
<select name="DrpBoxTbl0" id="DrpBoxTbl0">
<option value="Value1">Value1</option>
<select name="DrpBoxTbl1" id="DrpBoxTbl1">
<option value="Value2">Value2</option>
What i hope to achieve is the following
<select name="DrpBoxTbl0" id="DrpBoxTbl0">
<option value="Value1">Value1</option>
<option value="Value2">Value2</option>
<select name="DrpBoxTbl1" id="DrpBoxTbl1">
<option value="Value1">Value1</option>
<option value="Value2">Value2</option>
Can you please help?
i m selecting several values i.e value1 and value2 and after clicking a button i want based on these selected values to create Dynamically (2) drop down boxes and append to them the values of my previous selection.
So for example if on my listbox select 1 and 2 i want to create 2 dropdowns and each of them contain values 1 and 2 accordingly.
I use the following code which assumes that tbl1 is a listbox on my form:
Dim drpbox As DropDownList
If tbl1.SelectedIndex > -1 Then
For ctr = 0 To tbl1.Items.Count() - 1
If tbl1.Items(ctr).Selected Then
drpbox = New DropDownList
drpbox.ID = "DrpBoxTbl" & ctr
drpbox.SelectedIndex = -1
drpbox.Items.Add(tbl1.SelectedItem)
plhProductFields.Controls.Add(drpbox)
End If
Next
This results the following HTML:
<select name="DrpBoxTbl0" id="DrpBoxTbl0">
<option value="Value1">Value1</option>
<select name="DrpBoxTbl1" id="DrpBoxTbl1">
<option value="Value2">Value2</option>
What i hope to achieve is the following
<select name="DrpBoxTbl0" id="DrpBoxTbl0">
<option value="Value1">Value1</option>
<option value="Value2">Value2</option>
<select name="DrpBoxTbl1" id="DrpBoxTbl1">
<option value="Value1">Value1</option>
<option value="Value2">Value2</option>
Can you please help?