62,046
社区成员
发帖
与我相关
我的任务
分享
//全选、取消全选
protected void chkSelAll_CheckedChanged(object sender, EventArgs e)
{
CheckBox chkSelAll=(CheckBox)GridView1.BottomPagerRow.FindControl("chkSelAll");
Button btnDel = (Button)GridView1.BottomPagerRow.FindControl("btnDel");
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox chkSel = (CheckBox)GridView1.Rows[i].FindControl("ChkSel");
chkSel.Checked = (chkSelAll.Checked) ? true : false;
}
btnDel.Enabled = true;
}
//gridview中一个复选框取消选择全选取消选择
protected void chkSel_CheckedChanged(object sender, EventArgs e)
{
CheckBox chkSelAll=(CheckBox)GridView1.BottomPagerRow.FindControl("chkSelAll");
Button btnDel = (Button)GridView1.BottomPagerRow.FindControl("btnDel");
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox chkSel=(CheckBox)GridView1.Rows[i].FindControl("chkSel");
if (chkSel.Checked == true)
{
chkSelAll.Checked = false;
btnDel.Enabled = true;
break;//非常重要
}
else
{
btnDel.Enabled = false;
}
}
}