SmileyFace
Programmer
Hi everyone! I have spent hours trying to figure out whats wrong here. My patience is running out, it seems so simple but there is still a problem somewhere! I am basically using an add button to transfer dates selected in a calendar control to a listbox using.net. I also have a 'remove' button which is supposed to remove a selected item. Here is the problem...it removes an item alright...but it is ALWAYS the first listbox item, not the selected one!!
Here is the code..
For the button:
<asp:button id="btnRemove" runat="server" Font-Bold="True" Text="Remove"></asp:button>
The 'code behind' for this button is as follows:
Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click
Dim counter As Integer
For counter = lstVacation.Items.Count - 1 To 0 Step -1
If lstVacation.Items(counter).Selected = True Then
lstVacation.Items.RemoveAt(counter)
End If
Next
End Sub
I think it has something to do with the value, but cannot figure that out. ANY HELP WILL BE GREATLY APPRECIATED...THANKS! Here is the code
Here is the code..
For the button:
<asp:button id="btnRemove" runat="server" Font-Bold="True" Text="Remove"></asp:button>
The 'code behind' for this button is as follows:
Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click
Dim counter As Integer
For counter = lstVacation.Items.Count - 1 To 0 Step -1
If lstVacation.Items(counter).Selected = True Then
lstVacation.Items.RemoveAt(counter)
End If
Next
End Sub
I think it has something to do with the value, but cannot figure that out. ANY HELP WILL BE GREATLY APPRECIATED...THANKS! Here is the code