Exemple #1
0
        protected void gvUsers_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "EditUser")
            {
                int       userID    = Convert.ToInt32(e.CommandArgument);
                DataTable userTable = AdminDb.GetUserByID(userID);
                DataRow   row       = userTable.Rows[0];
                lbUserId.Text      = userID.ToString();
                tbFirstName.Text   = row["FirstName"].ToString();
                tbLastName.Text    = row["LastName"].ToString();
                tbEmail.Text       = row["Email"].ToString();
                tbPhoneNum.Text    = row["PhoneNum"].ToString();
                cbIsActive.Checked = Convert.ToBoolean(row["Active"]);
                cbIsAdmin.Checked  = Convert.ToBoolean(row["Admin"]);

                pnlUserEdit.Visible = true;
                pnlBackdrop.Visible = true;
            }
            else if (e.CommandName == "DeleteUser")
            {
                int userID = Convert.ToInt32(e.CommandArgument);
                AdminDb.DeleteUser(userID);
                BindDataToGridView();
            }
        }