protected override void ReadValueCore() { base.ReadValueCore(); if (PropertyValue is XPBaseCollection) { ASPxCheckBoxList control = ViewEditMode == DevExpress.ExpressApp.Editors.ViewEditMode.Edit ? Editor : InplaceViewModeEditor; if (control == null) { return; } control.SelectedIndexChanged -= new EventHandler(Control_SelectedIndexChanged); checkedItems = (XPBaseCollection)PropertyValue; XPCollection dataSource = new XPCollection(checkedItems.Session, MemberInfo.ListElementType); IModelClass classInfo = application.Model.BOModel.GetClass(MemberInfo.ListElementTypeInfo.Type); if (checkedItems.Sorting.Count > 0) { dataSource.Sorting = checkedItems.Sorting; } else if (!String.IsNullOrEmpty(classInfo.DefaultProperty)) { dataSource.Sorting.Add(new SortProperty(classInfo.DefaultProperty, DevExpress.Xpo.DB.SortingDirection.Ascending)); } control.DataSource = dataSource; control.TextField = classInfo.DefaultProperty; control.ValueField = classInfo.KeyProperty; control.ValueType = classInfo.TypeInfo.KeyMember.MemberType; control.DataBind(); control.UnselectAll(); foreach (object obj in checkedItems) { control.Items.FindByValue(objectSpace.GetKeyValue(obj)).Selected = true; } control.SelectedIndexChanged += new EventHandler(Control_SelectedIndexChanged); } }
protected void chlRoles_Load(object sender, EventArgs e) { ASPxCheckBoxList cbl = sender as ASPxCheckBoxList; if (grdRoles.IsEditing) { //get all Roles cbl.DataSource = Roles.GetAllRoles().Where(r => !r.Equals("Master") && !r.Equals("Amerinode")); cbl.DataBind(); //get User string user = grdRoles.GetRowValues(grdRoles.EditingRowVisibleIndex, "UserName").ToString(); //mark the Roles the User belongs to foreach (ListEditItem le in cbl.Items) { le.Selected = Roles.IsUserInRole(user, le.Text); } } }
private void Set_functionlist(ASPxCheckBoxList ck, string list) { LogCallMethod(true); string[] listfunction = list.Split(','); ck.DataBind(); for (int i = 0; i < listfunction.Length; i++) { foreach (ListEditItem var in ck.Items) { if (var.Value.ToString() == listfunction[i]) var.Selected = true; } } LogCallMethod(false); }