Peter Dzuya

Peter Dzuya

  • NA
  • 313
  • 40.8k

Obtaining value an Enum from a gridview (Entity Framework)

Nov 30 2016 5:02 AM
Hi All,
 
I am trying to get an enum value  from a selected list in a grid. Could some one assist me please. My Code is displayed below.
 
private void barButtonAddNewRole_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) {
try{
var selectedRole = UserRolegridView.GetFocusedValue();
if (selectedRole == null){
MessageBox.Show("Please select a Role", "Stock 2017", MessageBoxButtons.OK, MessageBoxIcon.Stop);
return;
}
var selectedUser = UsergridView.GetFocusedRow() as User;
if(selectedUser == null) {
MessageBox.Show("Please select a User", "Stock 2017", MessageBoxButtons.OK, MessageBoxIcon.Stop);
return;
}
_userRole = new UserRole(){
LastEditedDate = DateTime.Now,
LastEditorUserId = CurrentUserInfo.User.UserId,
UserRoleName = ?
UserId = selectedUser.UserId,
CompanyBranchId = CurrentUserInfo.User.CompanyBranchId,
DeletedStatus = false
};
userRoleBindingSource.EndEdit();
_userRoleService.Insert(_userRole);
} catch(Exception ex) {
MessageBox.Show(ex.GetBaseException().Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
 
Thanks. 
 

Answers (1)