在WEB页上将当前容器下的控件初始化

 

///


        /// 将容器内的控制初始化
        ///

        ///
        public static void ClearControlVal(Control parent)
        {
            if (parent.Controls.Count > 0)
            {
                foreach (Control cc in parent.Controls)
                {
                    ClearControlVal(cc);
                }
            }
            else
            {
                Control c = parent;
                string tc = c.GetType().ToString().Trim();
                //string t = typeof(ExtAspNet.TextBox).ToString().Trim();
                //if (tc == t)
                //{
                //    ((ExtAspNet.TextBox)c).Text = "only you can do.";
                //}
                switch (tc)
                {
                    case "ExtAspNet.TextBox":
                        ((ExtAspNet.TextBox)c).Text = "";
                        break;
                    case "ExtAspNet.DropDownList":
                        ((ExtAspNet.DropDownList)c).SelectedIndex = 0;
                        break;
                    case "ExtAspNet.RadioButton":
                        ((ExtAspNet.RadioButton)c).Checked = false;
                        break;
                    case "ExtAspNet.RadioButtonList":
                        ((ExtAspNet.RadioButtonList)c).Checked = false;//!!注意测试
                        break;
                    case "ExtAspNet.CheckBox":
                        ((ExtAspNet.CheckBox)c).Checked = false;
                        break;
                    case "ExtAspNet.TextArea":
                        ((ExtAspNet.TextArea)c).Text = "";
                        break;
                    default:
                        break;
                }

            }
        }

你可能感兴趣的:(.net数据库操作)