protected void UpdateStudent(object sender, EventArgs e) { int addressId = 0, studentId = 0; if (Session[SessionVariables.StudentSelectedToUpdate] != null) { var student = PageDataService.GetStudentAdoNet(Convert.ToInt32(Session[SessionVariables.StudentSelectedToUpdate].ToString())); if (student != null) { studentId = student.StudentId; addressId = student.AddressId; } } if (txtStudentName != null && txtMotherName != null && txtFatherName != null && txtAge != null && ddlGender != null && ddlClassInAddStudent != null && ddlSectionInAddStudent != null && ddlMediumInAddStudent != null && ddlCastInAddStudent != null && txtAddressLineOne != null && txtVillage != null && txtDistrict != null && txtPincode != null) { if (!String.IsNullOrEmpty(txtStudentName.Text.Trim()) && !String.IsNullOrEmpty(txtMotherName.Text.Trim()) && !String.IsNullOrEmpty(txtAge.Text.Trim()) && !String.IsNullOrEmpty(txtFatherName.Text.Trim()) && !String.IsNullOrEmpty(txtAddressLineOne.Text.Trim()) && !String.IsNullOrEmpty(txtVillage.Text.Trim()) && !String.IsNullOrEmpty(txtDistrict.Text.Trim()) && !String.IsNullOrEmpty(txtPincode.Text.Trim())) { if (addressId != 0) { PageDataService.UpdateAddressInAdoNet(addressId, txtAddressLineOne.Text, txtVillage.Text, txtDistrict.Text, txtPincode.Text); } if (studentId != 0) { PageDataService.UpdateStudentAdoNet(studentId, txtStudentName.Text.Trim(), txtMotherName.Text.Trim(), txtFatherName.Text.Trim(), Convert.ToInt32(txtAge.Text.Trim()), ddlGender.SelectedValue, Convert.ToInt32(ddlClassInAddStudent.SelectedValue), Convert.ToInt32(ddlSectionInAddStudent.SelectedValue), Convert.ToInt32(ddlCastInAddStudent.SelectedValue), Convert.ToInt32(ddlMediumInAddStudent.SelectedValue)); PageDataService.UpdateCurrentYearAccountAdoNet(studentId, Convert.ToInt32(ddlClassInAddStudent.SelectedValue), Convert.ToInt32(ddlMediumInAddStudent.SelectedValue)); } } } Session.Remove(SessionVariables.StudentSelectedToUpdate); Response.Redirect(Request.RawUrl, false); }