public void Clear(System.Web.UI.Control topctrl) 
{
foreach (System.Web.UI.Control ctrl in topctrl.Controls)
{
if (ctrl.GetType().Name== "TextBox")
if (ctrl.ID != "tbEditShijian")
((TextBox)ctrl).Text = "";//清空TextBox
else
((TextBox)ctrl).Text = DateTime.Now.ToString("HH:mm:ss");
else if (ctrl.GetType().Name == "CheckBoxList")//清空CheckBoxList
{
CheckBoxList cbl = ctrl as CheckBoxList;
for (int i = 0; i < cbl.Items.Count; i++)
{
cbl.Items[i].Selected = false;
}
}
else if(...............)
          ........
if (ctrl.HasControls())
Clear(ctrl);
}
}

 

 posted on 2012-03-21 16:37  纳米程序员  阅读(359)  评论(0编辑  收藏  举报