Attach client-side script within RowDataBound event handler:
<asp:GridView id="GridView1"
OnRowDataBound="GridView1_RowDataBound" ...
<Columns>
<asp:templateField>
<itemtemplate><sp:CheckBox id="CheckBox1" runat="server"></
itemtemplate>
</asp:templateField>
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
CheckBox CheckBox1 = (CheckBox)e.Row.FindControl("CheckBox1");
CheckBox1.Attributes["onclick"] = string.Format("alert({0});",
e.Row.RowIndex);
}
}