您的位置:首页 > 其它

3种方式遍历repeater中的控件,可作为CheckBox全选

2005-09-11 00:08 435 查看
方式1:
foreach (Control c in this.Repeater1.Controls)
{
HtmlInputCheckBox check = (HtmlInputCheckBox)c.FindControl("cbDelete1");
if( check != null )
{
check.Checked = true;
}
}
方式2:
for (int i=0;i<this.Repeater1.Items.Count;i++)
{
HtmlInputCheckBox check = (HtmlInputCheckBox)this.Repeater1.Items[i].FindControl("cbDelete1");
if( check != null )
{
check.Checked = true;
}
}
方式3:
foreach( RepeaterItem item in this.Repeater1.Items )
{
HtmlInputCheckBox check = (HtmlInputCheckBox)item.FindControl("cbDelete1");
if( check != null )
{
check.Checked = true;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: