/// <summary> /// Add a new CSDataRow which contains embedded control type info /// </summary> /// <param name="ctlType">embedded control type</param> /// <returns></returns> public CSDataRow NewRow(EmbedControlType ctlType) { CSDataRow dr = this.NewRow() as CSDataRow; dr.Tag = ctlType; this.Rows.Add(dr); return(dr); }
public override void SetContent() { CSDataRow dr = (RowInfo.DataBoundItem as DataRowView).Row as CSDataRow; dr.EmbeddedCtlPara.CtlCell = this; if (dr == null) { base.SetContent(); return; } EmbedControlType ctlType = (EmbedControlType)dr.Tag; switch (ctlType) { case EmbedControlType.CheckBox: UpdateVisibility(ctlChk); object value = this.Value; if (value == null || value == DBNull.Value || bool.FalseString.Equals(value.ToString())) { ctlChk.ToggleState = ToggleState.Off; } else { ctlChk.ToggleState = ToggleState.On; } break; case EmbedControlType.CheckComboBox: AddItem2ComboBox(ctlCheckComboBoxElement, dr); UpdateVisibility(ctlCheckComboBoxElement); ctlCheckComboBoxElement.CheckedNames = this.Value.ToString(); break; case EmbedControlType.CSComboBoxExx: AddItem2ComboBox(ctlComboBoxExxElement, dr); UpdateVisibility(ctlComboBoxExxElement); bool hasValue1 = false; foreach (RadItem item in ctlComboBoxExxElement.Items) { if (item.Text.Equals(this.Value)) { ctlComboBoxExxElement.SelectedItem = item; if (ctlComboBoxExxElement.IsPopupOpen) { ctlComboBoxExxElement.ListBoxElement.Focus(); } hasValue1 = true; break; } } if (!hasValue1) { ctlComboBoxExxElement.SelectedIndex = -1; } break; case EmbedControlType.ComboBox: AddItem2ComboBox(ctlComboBoxElement, dr); UpdateVisibility(ctlComboBoxElement); bool hasValue = false; foreach (RadItem item in ctlComboBoxElement.Items) { if (item.Text.Equals(this.Value)) { ctlComboBoxElement.SelectedItem = item; hasValue = true; break; } } if (!hasValue) { ctlComboBoxElement.SelectedIndex = -1; } break; case EmbedControlType.TextBox: UpdateVisibility(ctlTextBox); ctlTextBox.Text = this.Value.ToString(); break; case EmbedControlType.DateTimePicker: UpdateVisibility(ctlDataTimePickerElement); DateTime dt = DateTime.Now; DateTime.TryParse(this.Value.ToString(), out dt); ctlDataTimePickerElement.Value = dt; break; case EmbedControlType.ColorSelector: UpdateVisibility(ctlTextBox); ctlColorSelectorElement.Value = this.Value; break; case EmbedControlType.Spin: UpdateVisibility(ctlSpin); decimal result = 0; if (decimal.TryParse(this.Value.ToString(), out result)) { ctlSpin.Value = decimal.Parse(this.Value.ToString()); } else { ctlSpin.Value = 0; } break; case EmbedControlType.CSNumericTextBox: UpdateVisibility(ctlNumericTextBox); ctlNumericTextBox.Text = this.Value.ToString(); break; case EmbedControlType.CSIntTextBox: UpdateVisibility(ctlIntTextBox); ctlIntTextBox.Text = this.Value.ToString(); break; } }