'Check or UnCheck all the checkboxes based on header checkbox and change row color
Protected Sub ckHeader_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim chHeader As CheckBox
Dim chSelect As CheckBox
Dim cHeader As Boolean
Dim count As Integer
Dim gvr As DataGridItem
count = -1
Try
chHeader = CType(CMSgrid.Controls(0).Controls(1).FindControl("ckHeader"), CheckBox)
cHeader = chHeader.Checked
For Each gvr In CMSgrid.Items
count = count + 1
chSelect = CType(gvr.FindControl("ckSelect"), CheckBox)
If (cHeader = True) Then
gvr.BackColor = Color.Gold
gvr.ForeColor = Color.Black
chSelect.Checked = True
Else
If (count Mod 2) = 0 Then
gvr.BackColor = Color.LightGoldenrodYellow
gvr.ForeColor = Color.Black
Else
gvr.BackColor = Color.PaleGoldenrod
gvr.ForeColor = Color.Black
End If
chSelect.Checked = False
End If
Next
Catch ex As Exception
UserMsgBox(ex.Message)
WriteToLog(ex.Message)
End Try
End Sub
Where chHeader indicates the main checkbox.
By inspecting the above code, hopefully you can understand how to make it.