/// <summary>
    /// Sets selected item of the <see cref="DropDownList"/> or text of the <see cref="TextBoxControl"/> based on the given <paramref name="value"/>.
    /// </summary>
    /// <param name="value">Value to be set</param>
    protected override void SetControlValue(object value)
    {
        LoadAndSelectList();

        if (FieldInfo != null)
        {
            value = ConvertInputValue(value);
        }

        string selectedValue = ValidationHelper.GetString(value, String.Empty);

        if (value != null)
        {
            EnsureActualValueAsItem(selectedValue);
        }

        if (EditText)
        {
            txtCombo.Text = selectedValue;
        }
        else
        {
            dropDownList.ClearSelection();

            FormControlsHelper.SelectSingleValue(selectedValue, dropDownList, !CaseSensitiveSelection);
        }
    }
Пример #2
0
    /// <summary>
    /// Loads field with values from FormFieldInfo.
    /// </summary>
    public void Reload()
    {
        if (FieldInfo != null)
        {
            bool isMacro;
            txtDescription.SetValue(FieldInfo.GetPropertyValue(FormFieldPropertyEnum.FieldDescription, out isMacro), isMacro);
            txtFieldCaption.SetValue(FieldInfo.GetPropertyValue(FormFieldPropertyEnum.FieldCaption, out isMacro), isMacro);
            txtExplanationText.SetValue(FieldInfo.GetPropertyValue(FormFieldPropertyEnum.ExplanationText, out isMacro), isMacro);

            if (ShowInheritanceSettings)
            {
                chkControlInheritable.Checked = FieldInfo.Inheritable;
            }

            // Field visibility
            if (ShowFieldVisibility)
            {
                chkChangeVisibility.Checked = FieldInfo.AllowUserToChangeVisibility;
                Visibility = FieldInfo.Visibility;

                // Load controls for user visibility
                drpVisibilityControl.DataSource = FormUserControlInfoProvider.GetFormUserControls("UserControlCodeName, UserControlDisplayName", "UserControlForVisibility = 1", "UserControlDisplayName");
                drpVisibilityControl.DataBind();

                FormControlsHelper.SelectSingleValue(FieldInfo.VisibilityControl, drpVisibilityControl, true);
            }

            plcVisibility.Visible = ShowFieldVisibility;

            if ((Mode == FieldEditorModeEnum.BizFormDefinition) || (Mode == FieldEditorModeEnum.AlternativeBizFormDefinition))
            {
                chkPublicField.Checked = FieldInfo.PublicField;
            }

            string selectedItem;
            // Get control name from settings
            if (!String.IsNullOrEmpty(Convert.ToString(FieldInfo.Settings["controlname"])))
            {
                selectedItem = Convert.ToString(FieldInfo.Settings["controlname"]);
            }
            // Or get control name from field type
            else
            {
                selectedItem = FormHelper.GetFormFieldControlTypeString(FieldInfo.FieldType);
            }

            var fi = FormUserControlInfoProvider.GetFormUserControlInfo(selectedItem);

            FieldType = (fi != null) ? selectedItem : FormHelper.GetFormFieldDefaultControlType(AttributeType, GetControlsToDisplay());

            LoadFieldTypes(FieldInfo.PrimaryKey);
        }
        // If FormFieldInfo is not specified then clear form
        else
        {
            chkPublicField.Checked = true;
            ctrlVisibility.Value   = null;
            drpVisibilityControl.ClearSelection();
            chkChangeVisibility.Checked = false;
            txtFieldCaption.SetValue(null);
            txtDescription.SetValue(null);
            txtExplanationText.SetValue(null);
            drpControl.Reload(false);
            drpControl.Value = FormHelper.GetFormFieldDefaultControlType(AttributeType, GetControlsToDisplay());
        }
    }