I have a listbox (using
VB.NET) with the following values:
Add
Delete
Edit
View
I want to "loop" through the list and ONLY write the SELECTED ITEMS to the screen. I have the below code writtern, but I only get the first selected item. EX: If I select Add & View, my reslut on the screen is Add Add.
----------START CODE---------------------
Sub SaveUserPermission(ByVal s As Object, ByVal e As EventArgs)
Dim mUserID, mPermissionID As Integer
Dim txtPermission As String
Dim LI As ListItem
Dim objUserPermission As New clsUserPermission()
mUserID = Session("editID")
If lstbxPermissions.SelectedIndex = -1 Then
Response.Write("NOTHING IS SELECTED!")
End If
For Each LI In lstbxPermissions.Items
If LI.Selected = True Then
txtPermission = lstbxPermissions.SelectedItem.Text
Response.Write(txtPermission)
Response.Write("<br>")
End If
Next
End Sub
------------------END CODE-------------------------------
Please any help would be greatly appreciated!!!
Thanks,
MGR