protected void btnAdd_Click(object sender, EventArgs e) { try { if (Page.IsValid) { int userId = CurrentEnvironment.LoggedUser.Id; string machineName = Request.ServerVariables["REMOTE_HOST"].ToString(); int i = 0; if ((lbActions.Items.Count > 0)) { RoleAction o = new RoleAction(); o.RoleId = int.Parse(ddlRole.SelectedValue); for (int j = 0; j <= lbActions.Items.Count - 1; j++) { if (lbActions.Items[j].Selected) { int actionId = int.Parse(lbActions.Items[j].Value.ToString()); if (RoleAction.Exists(o.RoleId, actionId) == 0) { o.ActionId = actionId; o.IsActive = true; i = RoleAction.Insert(o); } } } _actions = Actions.GetLeftActionsOfRole(o.RoleId); BindLeftActionsOfRole(_actions); _roleActions = Actions.GetActionsOfRole(o.RoleId); BindActionsOfRole(_roleActions); } } } catch (Exception ex) { lblSuccess.Visible = false; lblWarning.Visible = false; lblError.Visible = true; } }