Example #1
0
        public List <StatsUser> CollectFormData(bool includeEmpty)
        {
            List <StatsUser> users = new List <StatsUser>();

            foreach (GridViewRow row in gvUsers.Rows)
            {
                CheckBox chkOwner     = (CheckBox)row.FindControl("chkOwner");
                CheckBox chkAdmin     = (CheckBox)row.FindControl("chkAdmin");
                TextBox  txtUsername  = (TextBox)row.FindControl("txtUsername");
                TextBox  txtPassword  = (TextBox)row.FindControl("txtPassword");
                TextBox  txtFirstName = (TextBox)row.FindControl("txtFirstName");
                TextBox  txtLastName  = (TextBox)row.FindControl("txtLastName");

                // create a new HttpError object and add it to the collection
                StatsUser user = new StatsUser();
                user.IsOwner   = chkOwner.Checked;
                user.IsAdmin   = chkAdmin.Checked;
                user.Username  = txtUsername.Text.Trim();
                user.Password  = txtPassword.Text.Trim();
                user.FirstName = txtFirstName.Text.Trim();
                user.LastName  = txtLastName.Text.Trim();

                if (includeEmpty || user.Username != "")
                {
                    users.Add(user);
                }
            }

            return(users);
        }
Example #2
0
        public void AddNewUser(List <StatsUser> users, bool isAdmin, bool isOwner)
        {
            StatsUser user = new StatsUser();

            user.IsAdmin   = isAdmin;
            user.IsOwner   = isOwner;
            user.Username  = "";
            user.Password  = "";
            user.FirstName = "";
            user.LastName  = "";
            users.Add(user);
        }
Example #3
0
        protected void gvUsers_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            ImageButton cmdDelete = (ImageButton)e.Row.FindControl("cmdDelete");
            CheckBox    chkAdmin  = (CheckBox)e.Row.FindControl("chkAdmin");

            if (cmdDelete != null)
            {
                cmdDelete.CommandArgument = e.Row.RowIndex.ToString();
            }

            StatsUser user = (StatsUser)e.Row.DataItem;

            if (user != null && user.IsOwner)
            {
                cmdDelete.Visible = false;
                chkAdmin.Enabled  = false;
            }
        }