Adf.Web.Binding.ListBoxPersister.Persist C# (CSharp) Method

Persist() public method

Persists the selected value of the specified System.Web.UI.WebControls.DropDownList to the specified property of the specified object.
public Persist ( object bindableObject, PropertyInfo pi, object control ) : void
bindableObject object The object where to persist.
pi System.Reflection.PropertyInfo The property of the object where to persist.
control object The , /// the selected value of which is to persist.
return void
        public void Persist(object bindableObject, PropertyInfo pi, object control)
        {
            var listBox = control as ListBox;

            if (listBox == null)
                return;

            if (!listBox.Enabled || !listBox.Visible)
                return;

            object value = pi.GetValue(bindableObject, null);
            if (value is IDomainObject)
            {
                PropertyHelper.SetValue(bindableObject, pi, IdManager.New(listBox.SelectedValue));
            }
            else if (value is Enum)
            {
                PropertyHelper.SetValue(bindableObject, pi, listBox.SelectedValue);
            }
            else
            {
                PropertyHelper.SetValue(bindableObject, pi, listBox.SelectedValue);
            }
        }
ListBoxPersister