在用GridView实现全选的反选时出错,,,求解!!!
protected void CheckBox1_CheckedChanged(object sender, EventArgs e) {
CheckBox cb = (CheckBox)sender;
if (cb.Text == "全选")
{
foreach (GridViewRow gv in this.GridView1.Rows)
{
CheckBox cd = (CheckBox)gv.FindControl("CheckBox1");
cd.Checked = cb.Checked;
cb.Text = "反选";
}
}
else
{
cb.Text = "反选";
foreach (GridViewRow gv in this.GridView1.Rows)
{
CheckBox cd = (CheckBox)gv.FindControl("CheckBox1");
cd.Checked = cb.Checked;(提示的出错位置!)
cb.Text = "全选";
}
}
}