#region 清除 protected void btnClear_Click(
object sender, EventArgs e) {
foreach (Control ctl
in this.Controls) {
this.txtClear(ctl); } }
#endregion private void txtClear(Control ctls) {
if(ctls.HasControls()) {
foreach (Control ctl
in ctls.Controls) { txtClear(ctl); } }
else {
if (ctls.GetType().Name ==
"TextBox") { TextBox tb =
new TextBox(); tb = (TextBox)
this.FindControl(ctls.ID); tb.Text =
""; }
else if (ctls.GetType().Name ==
"DropDownList") { DropDownList ddl =
new DropDownList(); ddl = (DropDownList)
this.FindControl(ctls.ID); ddl.SelectedIndex = 1; } } }
转载于:https://www.cnblogs.com/hengbo/archive/2009/01/05/2232510.html
相关资源:数据结构—成绩单生成器