Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to return listitem that has been removed?
    primarykey
    data
    text
    <p>I have a checkboxlist whith several options. The option(s) selected is/are removed from a second checkboxlist. This works fine in the below code. The problem is when the user changes the selected option in checkboxlist 1 the second checkboxlist still has the original option removed. How can I change this? Note: the dropdownlist helps the user continue with the form.</p> <p>page.aspx</p> <pre><code> &lt;asp:CheckBoxList ID="CheckBoxList1" runat="server" AutoPostBack="true"&gt; &lt;asp:ListItem Value="3"&gt;Italian&lt;/asp:ListItem&gt; &lt;asp:ListItem Value="6"&gt;Chinese&lt;/asp:ListItem&gt; &lt;asp:ListItem Value="7"&gt;Japanese&lt;/asp:ListItem&gt; &lt;asp:ListItem Value="8"&gt;Russian&lt;/asp:ListItem&gt; &lt;asp:ListItem Value="9"&gt;Arabic&lt;/asp:ListItem&gt; &lt;asp:ListItem Value="10"&gt;Hebrew&lt;/asp:ListItem&gt; &lt;asp:ListItem Value="11"&gt;Persian&lt;/asp:ListItem&gt; &lt;asp:ListItem Value="12"&gt;Turkish&lt;/asp:ListItem&gt; &lt;/asp:CheckBoxList&gt; </code></pre> <p>...</p> <pre><code> &lt;asp:DropDownList ID="DropDownList1" Width="100px" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"&gt; &lt;asp:ListItem Value=""&gt;Select&lt;/asp:ListItem&gt; &lt;asp:ListItem Value="Yes"&gt;Yes&lt;/asp:ListItem&gt; &lt;asp:ListItem Value="No"&gt;No&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt; </code></pre> <p>page.aspx.vb</p> <pre><code> Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged Dim li2 As ListItem Dim values As String = "" For i As Integer = 0 To CheckBoxList1.Items.Count - 1 If CheckBoxList1.Items(i).Selected Then values += CheckBoxList1.Items(i).Value + "," End If Next values = values.TrimEnd(","c) Dim ints As String() = values.ToString.Split(",") Dim y As Integer If DropDownList1.SelectedValue = "Yes" Then For y = 0 To UBound(ints) li2 = CheckBoxList2.Items.FindByValue(ints(y)) If Not IsNothing(li2) Then CheckBoxList2.Items.Remove(li2) End If Next end if End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload