全选代码: protected void Allchk_Click(object sender, EventArgs e) { foreach (RepeaterItem rp in Repeater1.Items) { CheckBox cbox = (CheckBox)rp.FindControl("chkMorePic"); if (cbox.Checked == false) { cbox.Checked = true; } else
{ cbox.Checked = false; } } } 取消代码: protected void rechk_Click(object sender, EventArgs e) { for (int i = 0; i <= Repeater1.Items.Count - 1; i++) { CheckBox check = (CheckBox)Repeater1.Items[i].FindControl("chkMorePic"); check.Checked = false; } } 我看你代码中并没有反选按钮么,如果要实现反选功能的话代码如下: protected void Button1_Click(object sender, EventArgs e) { foreach (RepeaterItem rp in Repeater1.Items) { CheckBox cbox = (CheckBox)rp.FindControl("chkMorePic"); if (cbox.Checked == true) { cbox.Checked = false; } else { cbox.Checked = true; } } }
|
请发表评论