Author: muybn | Posted on: 9/2/2008 1:45:57 AM | Views : 267

What is the correct way for finding and checking or unchecking checkboxes, dependent on a main checkbox toggled check/uncheck all? The code below produced the error Unable to cast object of type 'System.Web.UI.Control' to type 'System.Web.UI.WebControls.CheckBox' on the For Each line.

    Protected Sub chkAll_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
        Dim chk as CheckBox
If sender.Checked = True Then
For Each chk As CheckBox In lsvEditProfile.Controls
chk.Checked = True
Next
Else
For Each chk As Go to the complete details ...