Hi rhino000,
Refer below code you can assign the checkbox id like below but you can access the id at client side.
C#
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
{
if (e.Row.RowType == DataControlRowType.Header)
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
CheckBox checkBox = new CheckBox();
string val = e.Row.Cells[i].Text;
checkBox.Text = val.ToString();
checkBox.ID = "chk" + Convert.ToInt32(i).ToString();
checkBox.Attributes.Add("class", "dynamicCheckbox");
e.Row.Cells[i].Controls.Add(checkBox);
}
}
}
}
Jquery
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$('.dynamicCheckbox').click(function () {
$(this).closest('tr').find('[id*=chk]').each(function () {
if ($(this).is(':checked')) {
alert($(this).attr('id').split('_')[$(this).attr('id').split('_').length - 1]);
}
else {
$(this).attr('checked', false);
}
});
});
});
</script>