Current filter:
                                You should refresh the page.
                                  • I trying to implement ASPxComboBox control with Dynamic List Population as it described in here .
                                    I did some modification to make it work with XPO.


                                    The Collection items loading and filtering work fast with 100k records, I like it, but when I saving my business object then the value stored in combo box becomes empty.


                                    Am I missing something?


                                    My ASPxComboBox  implementation is here:

                                    [C#]
                                    namespace DocsVisionXAF.Module.Web.Editors { [PropertyEditor(typeof(CatalogCurrency), true)] public class MyComboBoxCatalogCurrency : ASPxPropertyEditor, IComplexViewItem { public MyComboBoxCatalogCurrency(Type objectType, IModelMemberViewItem info) : base(objectType, info) { } IObjectSpace objectSpace; private ASPxComboBox CreateCombo() { ASPxComboBox dropDownControl = new ASPxComboBox(); dropDownControl.Columns.Add(new ListBoxColumn("Name", "Валюта")); dropDownControl.TextFormatString = "{0}"; //dropDownControl.TextField = "Name"; dropDownControl.AllowNull = true; dropDownControl.CallbackPageSize = 20; dropDownControl.EnableCallbackMode = true; dropDownControl.EnableViewState = false; dropDownControl.IncrementalFilteringDelay = 100; dropDownControl.IncrementalFilteringMode = IncrementalFilteringMode.Contains; dropDownControl.ValueField = MemberInfo.MemberTypeInfo.KeyMember.Name; dropDownControl.ValueType = MemberInfo.MemberTypeInfo.KeyMember.MemberType; //dropDownControl.ValueChanged += EditValueChangedHandler; dropDownControl.ItemsRequestedByFilterCondition += DropDownControl_ItemsRequestedByFilterCondition; dropDownControl.ItemRequestedByValue += DropDownControl_ItemRequestedByValue; return dropDownControl; } private void DropDownControl_ItemRequestedByValue(object source, ListEditItemRequestedByValueEventArgs e) { ASPxComboBox comboBox = (ASPxComboBox)source; Session session = ((XPObjectSpace)objectSpace).Session; if (e.Value != null) { CatalogCurrency obj = null; if (e.Value is CatalogCurrency) { obj = session.GetObjectByKey<CatalogCurrency>(((CatalogCurrency)e.Value).Oid); } else if (e.Value is Guid) { obj = session.GetObjectByKey<CatalogCurrency>(e.Value); } if (obj != null) { comboBox.DataSource = new CatalogCurrency[] { obj }; comboBox.DataBind(); } } } private void DropDownControl_ItemsRequestedByFilterCondition(object source, ListEditItemsRequestedByFilterConditionEventArgs e) { ASPxComboBox comboBox = (ASPxComboBox)source; Session session = ((XPObjectSpace)objectSpace).Session; XPCollection<CatalogCurrency> collection = new XPCollection<CatalogCurrency>(session); collection.SkipReturnedObjects = e.BeginIndex; collection.TopReturnedObjects = e.EndIndex - e.BeginIndex + 1; collection.Sorting.Add(new SortProperty("Name", DevExpress.Xpo.DB.SortingDirection.Ascending)); if (e.Filter != "") collection.Criteria = new FunctionOperator(FunctionOperatorType.Contains, new OperandProperty("Name"), new OperandValue(e.Filter)); comboBox.DataSource = collection; comboBox.DataBind(); } protected override object GetControlValueCore() { if (Editor != null) { return Editor.Value == null ? null : objectSpace.GetObjectByKey(MemberInfo.MemberType, Editor.Value); } return base.GetControlValueCore(); } protected override WebControl CreateEditModeControlCore() { return CreateCombo(); } public new ASPxComboBox Editor { get { return (ASPxComboBox)base.Editor; } } #region IComplexViewItem Members public void Setup(DevExpress.ExpressApp.IObjectSpace objectSpace, DevExpress.ExpressApp.XafApplication application) { this.objectSpace = objectSpace; } #endregion } }




                                     
                                • Helen (DevExpress Support) 12.28.2016

                                  Hello Alexander,

                                  I reviewed your code and it looks correct, so I cannot say why this problem occurs without additional information. Would you please provide us with a sample project illustrating the issue? This way, we will be able to find the exact solution.

                                • Alexander Piseev 1 12.28.2016
                                  This is a sample project for you. 

                                1 Solution

                                Creation Date Importance Sort by
                                Hello Alexander,

                                It is necessary to override the ReadEditModeValueCore method in a custom property editor and manually assign the current property value to the editor, because different editors may use different properties for this purpose.
                                [C#]
                                protected override void ReadEditModeValueCore() { Editor.Value = PropertyValue == null ? null : objectSpace.GetKeyValue(PropertyValue); }

                                Also, I suggest that you uncomment the line in the constructor that subscribes to the ValueChanged event. For more details, please read the How to: Implement a Property Editor Based on Custom Controls (ASP.NET) article in our online documentation. I have attached a modified project for your reference.
                                • Alexander Piseev 1 12.29.2016
                                  Thank you, Uriah.

                                  Now it works perfect!

                                  p.s. I had to make some changes to it.
                                  [C#]
                                  protected override void ReadEditModeValueCore() { Editor.Value = PropertyValue == null ? null : objectSpace.GetKeyValue(PropertyValue); }

                                • Uriah (DevExpress Support) 12.29.2016
                                  You are right, it is necessary to check if the property value is null before passing it to the GetKeyValue method. I have updated the code in the Answer accordingly.