A couple of ways:
foreach (Control item in this.form1.Controls)
{
//We just need HtmlInputCheckBox
System.Web.UI.HtmlControls.HtmlInputCheckBox _cbx = item as System.Web.UI.HtmlControls.HtmlInputCheckBox;
if (_cbx != null)
{
if (_cbx.Checked)
{
//Do something:
Response.Write(_cbx.Name + " was checked.<br />");
}
}
}
or
//We just need HtmlInputCheckBox
IEnumerable<Control> _ctrls = from Control n in this.form1.Controls where n as System.Web.UI.HtmlControls.HtmlInputCheckBox != null select n;
if (_ctrls.Count() > 0)
{
foreach (System.Web.UI.HtmlControls.HtmlInputCheckBox item in _ctrls)
{
if (item.Checked)
{
//Do something:
Response.Write(item.Name + " was checked.<br/><br />");
}
}
}
Hope this helps....