Can't add handler to dynamically added radio buttons

  • Thread starter Thread starter Tee-Rob
  • Start date Start date
T

Tee-Rob

Guest
Using VS 2013, I have the following code in a simple webform page:

Using RDR = Com3.ExecuteReader()
If RDR.HasRows Then
Do While RDR.Read()
Dim rbtn As New RadioButton
With rbtn
rbtn.GroupName = "aaaaa"
rbtn.ID = "bbbbb" & i
rbtn.Text = Trim(RDR.Item("ccccc"))
rbtn.Checked = False

rbtn.Attributes.Add("value", i)
AddHandler rtbn.CheckedChanged, AddressOf rbtn_CheckedChanged
End With
Panel1.Controls.Add(rbtn)

Panel1.Controls.Add(New LiteralControl("<br />"))
Panel1.Controls.Add(New LiteralControl("<br />"))
i += 1
Loop
Session("ddddd") = (i - 1).ToString
End If
End Using

Have done many variations of this code over the last week, but am still getting the error message at the AddHandler line:

'rtbn' is not declared. It may be inaccessible due to its protection level.


Anyone have an idea of what I could try to fix this?

Continue reading...
 
Back
Top