protected void SaveButton_Click(object sender, EventArgs e)
        {
            // Use EF to connect to the server
            using (ContosoConnection db = new ContosoConnection())
            {
                // Use the Student model to create a new student object and save a new record
                Student newStudent = new Student();

                int StudentID = 0;

                if (Request.QueryString.Count > 0) // Our URL has a StudentID in it
                {
                    // Get the ID from the URL
                    StudentID = Convert.ToInt32(Request.QueryString["StudentID"]);

                    // Get the current student from EF DB
                    newStudent = (from student in db.Students
                                  where student.StudentID == StudentID
                                  select student).FirstOrDefault();
                }
                // Add data to the new student record
                newStudent.LastName = LastNameTextBox.Text;
                newStudent.FirstMidName = FirstNameTextBox.Text;
                newStudent.EnrollmentDate = Convert.ToDateTime(EnrollmentDateTextBox.Text);

                // Use LINQ to ADO.NET to add or insert new student into the database
                if (StudentID == 0)
                {
                    db.Students.Add(newStudent);
                }

                // Save our changes
                db.SaveChanges();

                // Redirect back to the updated students page
                Response.Redirect("~/Students.aspx");
            }
        }
        /**
         * <summary>
         * This event handler deletes a student from the db using EF
         * </summary>
         *
         * @method StudentsGridView_RowDeleting
         * @param {object} sender
         * @param {GridViewDeleteEventArgs} e
         * @returns {void}
         */
        protected void StudentsGridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            // Store which row was clicked
            int selectedRow = e.RowIndex;

            // Get the selected StudentID using the Grid's DataKey collection
            int StudentID = Convert.ToInt32(StudentsGridView.DataKeys[selectedRow].Values["StudentID"]);

            // Use EF to find the selected student in the DB and remove it
            using (ContosoConnection db = new ContosoConnection())
            {
                // Create object of the Student class and store the query string inside of it
                Student deletedStudent = (from studentRecords in db.Students
                                          where studentRecords.StudentID == StudentID
                                          select studentRecords).FirstOrDefault();

                // Remove the selected student from the db
                db.Students.Remove(deletedStudent);

                // Save my changes back to the database
                db.SaveChanges();

                //refresh the Grid
                this.GetStudents();
            }
        }
        /**
         * <summary>
         * This event handler deletes a department from the databse using EF
         * </summary>
         * @method DepartmentsGridView_RowDeleting
         * @param {object} sender
         * @param {GridViewDeleteEventArgs}
         * @returns {void}
         * */
        protected void DepartmentsGridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            // Store which row was clicked
            int selectedRow = e.RowIndex;

            // Get the selected DepartmentID using the grids datakey collection
            int DepartmentID = Convert.ToInt32(DepartmentsGridView.DataKeys[selectedRow].Values["DepartmentID"]);

            // Use ef to find the selelcted Department and delete it
            using (ContosoConnection db = new ContosoConnection())
            {
                // Create object of the department class and store the query string inside of it
                Department deletedDepartment = (from departmentRecords in db.Departments
                                                where departmentRecords.DepartmentID == DepartmentID
                                                select departmentRecords).FirstOrDefault();

                // Remove the selected department from the db
                db.Departments.Remove(deletedDepartment);

                // Save db changes
                db.SaveChanges();

                // Refresh gridview
                this.GetDepartments();

            }
        }