全选功能代码如下:
protected void Allchk_Click(object sender, EventArgs e)
{
foreach (RepeaterItem rp inRepeater1.Items)
{
CheckBoxcbox = (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++)
{
CheckBoxcheck = (CheckBox)Repeater1.Items[i].FindControl("chkMorePic");
check.Checked = false;
}
}
反选功能代码如下:
protected void Button1_Click(object sender, EventArgs e)
{
foreach (RepeaterItem rp inRepeater1.Items)
{
CheckBoxcbox = (CheckBox)rp.FindControl("chkMorePic");
if(cbox.Checked == true)
{
cbox.Checked = false;
}
else
{
cbox.Checked = true;
}
}
}
C#checkBox的全选取消和反选
最新推荐文章于 2021-09-12 16:51:39 发布