protected void gridViewRole_Command(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "Select")
     {
         GetMyAccessRights();
         modalLabelError.Text = "";
         modalLabelError.Visible = false;
         modalBtnSubmit.Visible = Convert.ToBoolean(myAccessRights.CanUpdate);
         int index = Convert.ToInt32(e.CommandArgument);
         int roleid = Convert.ToInt32(((Label)gridViewRole.Rows[index].FindControl("labelRoleId")).Text);
         modalBtnSubmit.CommandArgument = "Update";
         Roles role = new Roles();
         role = role.GetRole(roleid);
         modalLabelRoleId.Text = role.Id.ToString();
         modalTxtBoxDescription.Text = role.Description;
         this.programmaticModalPopup.Show();
     }
 }
 protected void modalBtnSubmit_Command(object sender, CommandEventArgs e)
 {
     if (modalLabelError.Visible == true)
         this.programmaticModalPopup.Show();
     else
     {
         int userid = Convert.ToInt32(Session["UserId"]);
         Roles role = new Roles();
         if (modalLabelRoleId.Text.Trim() != "")
         {
             role = role.GetRole(Convert.ToInt32(modalLabelRoleId.Text));
         }
         role.Description = modalTxtBoxDescription.Text.Trim();
         role.LastUpdateDate = DateTime.Now;
         role.LastUpdatedBy = userid;
         if (e.CommandArgument.ToString() == "Add")
         {
             role.CreateDate = DateTime.Now;
             role.CreatedBy = userid;
             role.Insert(role);
         }
         else if (e.CommandArgument.ToString() == "Update")
         {
             role.Update(role);
         }
         InitializeGridViewRole();
         this.programmaticModalPopup.Hide();
     }
 }
 protected void InitializeModalDropDownRoles(int roleid = 0)
 {
     Roles role = new Roles();
     List<Roles> datalist = new List<Roles>();
     if (roleid == 0) //Add
     {
         datalist = role.GetRolesWithoutModuleAccess();
         modalDropDownRoles.Enabled = true;
     }
     else //Update
     {
         role = role.GetRole(roleid);
         datalist.Add(role);
         modalDropDownRoles.Enabled = false;
     }
     modalDropDownRoles.DataSource = datalist;
     modalDropDownRoles.DataTextField = "Description";
     modalDropDownRoles.DataValueField = "Id";
     modalDropDownRoles.DataBind();
 }