private void RefreshMasterAccountActorComboBox(object sender)
        {
            //Clear selection
            ASPxCallbackPanel    panel = sender as ASPxCallbackPanel;
            AccountActorComboBox accountActorComboBox =
                (AccountActorComboBox)panel.FindControl("accountActorComboBox");

            accountActorComboBox.ComboBox.SelectedIndex = -1;

            UpdateMasterAccountActorComboBox(sender);
        }
        private void UpdateMasterAccountActorComboBox(object sender)
        {
            ASPxCallbackPanel panel = sender as ASPxCallbackPanel;
            GridViewEditItemTemplateContainer itemContainer = (GridViewEditItemTemplateContainer)panel.NamingContainer;
            ASPxGridView grid = itemContainer.Grid;
            //Get allocation
            ASPxComboBox allocationComboBox =
                (ASPxComboBox)grid.FindEditRowCellTemplateControl(grid.Columns["Allocation!Key"] as GridViewDataColumn, "cboAllocation");

            if (allocationComboBox.Value == null)
            {
                return;
            }
            Guid       allocationId = (Guid)allocationComboBox.Value;
            Allocation allocation   = session.GetObjectByKey <Allocation>(allocationId);
            //Get account actor type
            AllocationAccountActorType masterAllocationAccountActorType =
                allocation.AllocationAccountActorTypes.FirstOrDefault(r => r.IsMaster);

            if (masterAllocationAccountActorType == null)
            {
                throw new Exception("Invalid allocation. Make sure that the allocation has a master account actor type.");
            }
            AccountActorType accountActorType = masterAllocationAccountActorType.AccountActorTypeId;

            AccountActorTypeEnum accountActorTypeEnum =
                (AccountActorTypeEnum)Enum.Parse(typeof(AccountActorTypeEnum), accountActorType.Code);
            //Get account actor combobox
            AccountActorComboBox accountActorComboBox =
                (AccountActorComboBox)panel.FindControl("accountActorComboBox"); //FindEditRowCellTemplateControl(grid.Columns["MasterAccountActor"] as GridViewDataColumn, "accountActorComboBox");

            //Validation setting
            accountActorComboBox.ComboBox.ValidationSettings.ErrorDisplayMode         = ErrorDisplayMode.ImageWithTooltip;
            accountActorComboBox.ComboBox.ValidationSettings.RequiredField.IsRequired = true;
            accountActorComboBox.ComboBox.ValidationSettings.RequiredField.ErrorText  =
                (string)HttpContext.GetGlobalResourceObject("MessageResource", "Msg_Required_Select");
            //Set account actor combobox strategy
            accountActorComboBox.SetAccountActorComboBoxStrategy(
                AccountActorComboBoxStrategyCreators.GetCreator(accountActorTypeEnum).Create());
        }
        protected void gridVoucherAllocation_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            try
            {
                using (UnitOfWork uow = XpoHelper.GetNewUnitOfWork())
                {
                    if (VoucherId == null || VoucherId.Equals(Guid.Empty))
                    {
                        throw new Exception("The operation is not supported. Please set VoucherId for the gridview.");
                    }
                    //Code
                    //
                    e.NewValues["VouchesId!Key"] = VoucherId;

                    ASPxCallbackPanel panel = (ASPxCallbackPanel)gridVoucherAllocation
                                              .FindEditRowCellTemplateControl(
                        gridVoucherAllocation.Columns["MasterAccountActor"] as GridViewDataColumn,
                        "cpnMasterAcountActor");

                    AccountActorComboBox accountActorComboBox =
                        (AccountActorComboBox)panel.FindControl("accountActorComboBox");

                    WebModule.Accounting.AllocationConfigure.Controls.AccountActor accountActor =
                        accountActorComboBox.GetSelectedItem();

                    uow.CommitChanges();
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                e.Cancel = true;
                gridVoucherAllocation.CancelEdit();
            }
        }