static int kount=0;
protected void chkHead_CheckedChanged(object sender, EventArgs e)
{
CheckBox chhead = (CheckBox)gv.HeaderRow.FindControl("chkHead");
foreach (GridViewRow gr in gv.Rows)
{
CheckBox ch = (CheckBox)gr.Cells[1].FindControl("chkItem");
if (chhead.Checked)
ch.Checked = true;
else
ch.Checked = false;
}
}
protected void chkItem_CheckedChanged(object sender, EventArgs e)
{
CheckBox chhead = (CheckBox)gv.HeaderRow.FindControl("chkhead");
if (gv.Rows.Count == 1)
{
CheckBox sinch = (CheckBox)gv.Rows[0].FindControl("chkItem");
if (sinch.Checked)
chhead.Checked = true;
else
chhead.Checked = false;
}
else
{
foreach (GridViewRow gr in gv.Rows)
{
CheckBox ch = (CheckBox)gr.FindControl("chkItem");
if (ch.Checked)
kount++;
}
if (kount == gv.Rows.Count)
chhead.Checked = true;
else
{
kount = 0;
chhead.Checked = false;
}
}
}
No comments:
Post a Comment