/// <summary> /// Creates registrations for the courses that were selected /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void BtnAdd_Click(object sender, EventArgs e) { List <string> selectedCourseCodes = new List <string>(); foreach (GridViewRow row in GVCourses.Rows) { CheckBox chkSelection = (CheckBox)row.FindControl("ChkSelectCourse"); if (chkSelection.Checked) { selectedCourseCodes.Add(row.Cells[1].Text); } } CourseDAO courseDAO = new CourseDAO(connectionString); UserTableDAO userTableDAO = new UserTableDAO(connectionString); RegistrationRequestDAO registrationRequestDAO = new RegistrationRequestDAO(connectionString); foreach (string code in selectedCourseCodes) { Course course = courseDAO.SearchByCourseCode(code); User loggedInUser = userTableDAO.SearchByEmail(Context.User.Identity.Name); registrationRequestDAO.AddRegistrationRequest( new RegistrationRequest(loggedInUser, course, Status.NEW)); } // Redirect to dashboard so they can see the request went through Response.Redirect("./UserDashboard.aspx"); }