Exemplo n.º 1
0
 private void FindFieldValue(string field, ControlCollection objControls, ref string value)
 {
     foreach (Control control in objControls)
     {
         if (control.ID == field)
         {
             if (control is MyTextBox)
             {
                 MyTextBox box = (MyTextBox)control;
                 if (box.MaxCharLength == 0)
                 {
                     value = box.Text;
                 }
                 else
                 {
                     value = box.TextCut(box.MaxCharLength);
                 }
             }
             else if (control is MyXheditor)
             {
                 MyXheditor xheditor = (MyXheditor)control;
                 value = xheditor.Text;
             }
             else if (control is MyDropDownList)
             {
                 MyDropDownList list = (MyDropDownList)control;
                 value = list.SelectedValue;
             }
             else if (control is MyCheckBoxList)
             {
                 MyCheckBoxList list2 = (MyCheckBoxList)control;
                 value = list2.SelectValueString;
             }
             else if (control is MyRadioButtonList)
             {
                 MyRadioButtonList list3 = (MyRadioButtonList)control;
                 value = list3.SelectedValue;
             }
             else
             {
                 if (!(control is CheckBox))
                 {
                     throw new ArgumentException("未能识别" + field + "控制类型,请使用MyTextBox,MyDropDownList,MyCheckBoxList,MyRadioButtonList,CheckBox,MyXheditor的控件");
                 }
                 CheckBox box2 = (CheckBox)control;
                 value = box2.Checked.ToString();
             }
         }
         if (control.HasControls())
         {
             this.FindFieldValue(field, control.Controls, ref value);
         }
     }
 }