asp.net 遍历repeater中的控件的几种方式
程序员文章站
2024-03-08 22:32:46
方式1: 复制代码 代码如下: foreach (control c in this.repeater1.controls) { htmlinputcheckbox che...
方式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;
}
}
复制代码 代码如下:
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;
}
}