To do this in the code behind.
Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
If e.CommandName = "check" Then
GridView1.EditIndex = GridView1.SelectedIndex
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
Dim checkBox As CheckBox = GridView1.Rows(index).FindControl("ChkAll")
checkBox.Checked = true
End If
End Sub
If you want to do it in Javascript there is a nice article on CodeProject
Check/uncheck CheckBox in a GridView using Javascript[
^]