CheckedChabge dynamically

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have no idea how to get the IDs of dynamically genrated CheckBoxes and the
events of CheckedChange.

I have dynamically generated array of CheckBoxes, checkboxes,which
dynamically display in a table of a web form when Page_Load.
(1) I want determine if the status of checkboxes(i, j) from checked to
Unchecked or Array(k,j) from unchecked to checked.
(2) The procedure like the following can only be used for predefined the
checkbox in the form (i.e., the ID is already known). So it would not work
for me. How to get the IDs when they are dynamically generated (see (3))?
Private Sub CheckBox_CheckedChanged(ByVal sender As _
System.Object, ByVal e As System.EventArgs) Handles _
CheckBox.CheckedChanged
................
End Sub

(3) While the checkboxes, checkboxes(j, i), are generated, I use
checkBoxIDs(j, i) = checkboxes(j, i).ClientID
to try to get their ID. But it does not work.

Could anyone here give me help?

Thanks

David
 
when you create the checkboxes add a event handler to the
CheckedChanged event (for the dynamic checkbox), set the delegate to be
a method with the correct signature,

now when the page loads (even in post back) you first need to
reconstruct the checkboxes, the event will then be wired up
 
Back
Top