[Asp.Net]批量清楚控件的数据

来源:互联网 发布:中国科技引文数据库 编辑:程序博客网 时间:2024/05/22 15:17

/// <summary>   

   /// 清空所有的文本框  

/// </summary>   

   private void ClearAllTextBox()   

  {   

       foreach (Control control in this.groupBox1.Controls)   

       {                  

           if(control is TextBox)   

           {   

               ((TextBox)control).Text = "";   

           }   

       }   

   }  

 

if (control.GetType().ToString()=="System.Windows.Forms.TextBox")  

private void ClearTextBoxAndComboBoxAndCheckBox()   

 {    

     foreach (Control c in  this.Controls)   

     {   

         if (c.GetType().ToString().Contains("TextBox"))   

         {   

             ((TextBox)c).Text = "";   

         }   

         if (c.GetType().ToString().Contains("ComboBox"))   

         {   

             ((ComboBox)c).Text = "";   

         }   

         if (c.GetType().ToString().Contains("CheckBox"))   

         {   

             ((CheckBox)c).Checked = false;   

         }   

     }   

 }   

原创粉丝点击