Event firing twice


S

Slim

I have loop that builds table rows, it also attaches events, this works fine
on all but the last row, where the event fires twice

I have autowireup set to false

any ideas?



For i = 0 To UBound(oCountries.getCountries)

Dim tr As TableRow = New TableRow

Dim td As TableCell = New TableCell

btCountry = New Button

AddHandler btCountry.Click, AddressOf CountryButtClick

btCountry.OnClientClick = "waitForIt()"

btCountry.Attributes.Add("class", "dButtons")

btCountry.CommandArgument = oCountries.getCountries(i).id

btCountry.BackColor = Drawing.Color.Transparent

btCountry.BorderStyle = BorderStyle.None

btCountry.Text = oCountries.getCountries(i).Name

td.Controls.Add(btCountry)

tr.Cells.Add(td)

countryTable.Rows.Add(tr)

Next
 
Ad

Advertisements

M

Mark Rae

For i = 0 To UBound(oCountries.getCountries)

For i = 0 To UBound(oCountries.getCountries) - 1

I'm actually quite surprised your code doesn't generate an "index out of
bounds" error...
 
Ad

Advertisements

S

Slim

Mark Rae said:
For i = 0 To UBound(oCountries.getCountries) - 1

I'm actually quite surprised your code doesn't generate an "index out of
bounds" error...

If I put a -1 I get one value short, its when you use the count property you
need to use -1, I always get them mixed up myself.

But I found my problem, I was attaching a event plus I had the "handles
btCountry.Click" on the event also.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top