示例#1
0
        protected void GridViewAllAttendance_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow gvr = GridViewAllAttendance.Rows[e.RowIndex];

            var attID = int.Parse(GridViewAllAttendance.DataKeys[e.RowIndex].Values[0].ToString());

            var attendanceToUpdate = ac.GetAllAttendance().Where(x => x.id == attID).FirstOrDefault();

            TextBox att = (TextBox)gvr.FindControl("TextBoxAttendance");


            if (attendanceToUpdate != null)
            {
                if (att.Text == "False")
                {
                    attendanceToUpdate.Attendance1 = false;
                    ac.UpdateAttendance(attendanceToUpdate);
                }
                else if (att.Text == "True")
                {
                    attendanceToUpdate.Attendance1 = true;
                    ac.UpdateAttendance(attendanceToUpdate);
                }

                e.Cancel = true;
                GridViewAllAttendance.EditIndex = -1;
                BindGrid();
            }
        }