Add to your GridView:
<asp:GridView ID="GridView1" OnRowDataBound="GridView1_RowDataBound" ...
Change your JavaScript to this:
<script type="text/javascript">
<!--
function onCheckbox2Click(chkbox)
{
// Don't need this as it is being passed by the event...
//var chkbox = document.getElementById('<%=Checkbox2.ClientID%>');
// Rest of your code goes here...
}
// -->
</script>
Add to the CodeBehind:
protected void GridView1_RowDataBound(Object sender, GridViewRowEventArgs e)
{
if ( e.Row.RowType == DataControlRowType.DataRow )
{
// CheckBox with an ID of "Checkbox2" is in column #1 of the Grid...
Button checkBox2 = (Button)e.Row.Cells[1].FindControl("Checkbox2");
if ( checkBox2 != null )
checkBox2.Attributes.Add("onclick", "onCheckbox2Click(this);");
}
}
NC...