Tuesday, January 15, 2013

Empty all textboxes


  public static void EmptyTextBoxes(Control parent) 
    { 
        foreach (Control c in parent.Controls) 
        { 
        if (c.GetType() == typeof(TextBox)) 
        { 
        ((TextBox)(c)).Text = string.Empty; 
        }
        else if (c.GetType() == typeof(DropDownList)) 
        { 
            ((DropDownList)(c)).SelectedIndex = 0; 
        } 
           if (c.HasControls()) 
           { 
             EmptyTextBoxes(c); 
           } 
        } 
    }

No comments:

Post a Comment