I am trying to access 3 checkboxes on a page that were created dynamically from database info on PageLoad. I can see these checkboxes in the web Page Source with ID's equal to T1, T2 and T3. On viewing the page the boxes are checked or unchecked appropriately according to database table values. I am trying to determine the checked or unchecked states of these checkboxes and then writing it to the database on a button click. All of that is fine. My problem is the actual "accessing" of those checkboxes/their associated ID's. I have extensively researched and tried everything yet nothing seems to work. I'm sure I'm missing some little nuance. Here's my code (sorry the indenting is screwed up):
Dim RecCountT As Integer = TNotify.Rows.Count
For i = 0 to RecCountT - 1
Dim strSQLNotifyT as String = "UPDATE dbo._PinCodes SET TextOnOff = @TextOnOff WHERE EmployeeID = @EmployeeID"
Dim myCommand as New SqlCommand(strSQLNotifyT, Conn)
Dim CheckBoxID
CheckBoxID = "T" & i
If CheckBoxID.Checked = True Then
myCommand.Parameters.AddWithValue("@TextOnOff", "on")
ElseIf CheckBoxID.Checked = False Then
myCommand.Parameters.AddWithValue("@TextOnOff", "off")
End If
myCommand.Parameters.AddWithValue("@EmployeeID", TNotify.Rows(i)("EmployeeID").ToString())
Conn.Open()
myCommand.ExecuteNonQuery()
Conn.Close()
Next