Re: Code called twice

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Saravana (saravank_at_sct.co.in)
Date: 02/07/05


Date: Mon, 7 Feb 2005 23:10:58 +0530

Check out this faq,
http://www.extremeexperts.com/Net/FAQ/PageLoadFiringTwice.aspx

-- 
-Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com
"anonymous" <anonymous@discussions.microsoft.com> wrote in message
news:252201c50d34$f7aabef0$a401280a@phx.gbl...
> 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)

Quantcast