protected void Page_Load(object sender, EventArgs e) { bool valid = true; string studentid = Request.QueryString["studentid"]; if (String.IsNullOrEmpty(studentid)) { valid = false; } try { Int32.Parse(studentid); }//end of try catch (Exception ex) { //catching invalid URL ID entries valid = false; }//end of catch if (valid) { var db = new SCHOOLDB(); Dictionary <String, String> student_record = db.FindStudent(Int32.Parse(studentid)); List <Dictionary <String, String> > rs = db.List_Query("select STUDENTS.*,count(studentnumber) as 'Enrolled classes' from STUDENTS join STUDENTSXCLASSES on STUDENTSXCLASSES.STUDENTID = STUDENTS.STUDENTID group by STUDENTS.STUDENTNUMBER order by STUDENTFNAME asc"); if (student_record.Count > 0) { student_title_fname.InnerHtml = student_record["STUDENTFNAME"] + " " + student_record["STUDENTLNAME"]; student_fname.InnerHtml = student_record["STUDENTFNAME"]; student_lname.InnerHtml = student_record["STUDENTLNAME"]; student_number.InnerHtml = student_record["STUDENTNUMBER"]; enrolment_date.InnerHtml = student_record["ENROLMENTDATE"]; //classes_enrolled.InnerHtml = student_record["Enrolled classes"]; } else { valid = false; }//end of if } if (!valid) { error.InnerHtml = "There was an error finding that student."; student.Visible = false; }//end of if }
protected void Page_Load(object sender, EventArgs e) { bool valid = true; string studentid = Request.QueryString["studentid"]; if (String.IsNullOrEmpty(studentid)) { valid = false; } try { Int32.Parse(studentid); } catch (Exception ex) { //catching invalid URL ID entries valid = false; } if (valid) { var db = new SCHOOLDB(); Dictionary <String, String> student_record = db.FindStudent(Int32.Parse(studentid)); List <Dictionary <String, String> > rs = db.List_Query("select * from students order by studentfname asc"); if (student_record.Count > 0) { student_FullName.InnerHtml = student_record["STUDENTFNAME"] + " " + student_record["STUDENTLNAME"]; student_FName.Text = student_record["STUDENTFNAME"]; student_LName.Text = student_record["STUDENTLNAME"]; student_Number.Text = student_record["STUDENTNUMBER"]; enrolment_Date.Text = student_record["ENROLMENTDATE"]; } else { valid = false; } } if (!valid) { updatestudentForm.InnerHtml = "There was an error finding that student. <br />"; updatestudentForm.InnerHtml += "<button type=\"button\" class=\"btn btn-primary\" onclick=\"location.href = 'Students.aspx' \">Go Back</button>"; } }