foreach (Control c in parent.Controls) { if (c.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox")) { ((TextBox)c).Text = ""; } else if (c.GetType().ToString().Equals("System.Web.UI.WebControls.DropDownList")) { if (((DropDownList)c).Items.Count > 1) ((DropDownList)c).SelectedIndex = 0; } else if (c.GetType().ToString().Equals("System.Web.UI.WebControls.CheckBox")) { if (((CheckBox)c).Checked) ((CheckBox)c).Checked = false; }
else if (c.Controls.Count > 0) { if (!c.GetType().ToString().Equals("System.Web.UI.WebControls.GridView")) { InPutClear(c, but); }
<input type="reset" value="Clear" />
{
if (c.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox"))
{
((TextBox)c).Text = "";
}
else if (c.GetType().ToString().Equals("System.Web.UI.WebControls.DropDownList"))
{
if (((DropDownList)c).Items.Count > 1)
((DropDownList)c).SelectedIndex = 0;
}
else if (c.GetType().ToString().Equals("System.Web.UI.WebControls.CheckBox"))
{
if (((CheckBox)c).Checked)
((CheckBox)c).Checked = false;
}
else if (c.Controls.Count > 0)
{
if (!c.GetType().ToString().Equals("System.Web.UI.WebControls.GridView"))
{
InPutClear(c, but);
}
个人愚见 , 没试过