17 December 2013

how to use foreach loop for clear the all textboxes?

void CleareAllcontrolsRecursive(Control container)
    {
        foreach (var control in container.Controls)
        {
            if (control is TextBox)
            {
                ((TextBox)control).Text = string.Empty;


            }
            if (control is DropDownList)
            {
                ((DropDownList)control).SelectedValue = "0";
            }
        }
    }

No comments:

Post a Comment