A
anonymous
Hello,
I have a listbox control, which has multiple selection
enabled. Now, I need to retrieve all selected items when
the submit button is clicked. It works very well, but the
only problem is that it returns the data 2 times. I mean
it returns duplicated data. Lets say I selected one item,
and press the submit button. When I do a response.write
then I can see the item two times. Why is that happening?
My code:
Private Sub btnTest_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnTest.Click
Dim i As Integer
Dim str As String
For i = 0 To listStores.Items.Count - 1
If listStores.Items(i).Selected Then
str &= listStores.Items(i).Text
str &= str & ","
End If
Next
' strip of the last comma, which is always the
last position in the string
str = str.Substring(0, str.Length() - 1)
Response.Write(str)
I have a listbox control, which has multiple selection
enabled. Now, I need to retrieve all selected items when
the submit button is clicked. It works very well, but the
only problem is that it returns the data 2 times. I mean
it returns duplicated data. Lets say I selected one item,
and press the submit button. When I do a response.write
then I can see the item two times. Why is that happening?
My code:
Private Sub btnTest_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnTest.Click
Dim i As Integer
Dim str As String
For i = 0 To listStores.Items.Count - 1
If listStores.Items(i).Selected Then
str &= listStores.Items(i).Text
str &= str & ","
End If
Next
' strip of the last comma, which is always the
last position in the string
str = str.Substring(0, str.Length() - 1)
Response.Write(str)