protected void btnSave_Click(object sender, EventArgs e) { // connect var conn = new gurbhejEntities(); //use the Student class to create a new Student Object Student s = new Student(); // Fill the properties of the new student object s.LastName = txtLastName.Text; s.FirstMidName = txtFirstMidName.Text; s.EnrollmentDate = Convert.ToDateTime(txtEnrollment.Text); //save the new object to the database conn.Students.Add(s); conn.SaveChanges(); //redirect to the students page Response.Redirect("students.aspx"); }
protected void btnSave_Click(object sender, EventArgs e) { // connect var conn = new gurbhejEntities(); //use the Student class to create a new department Object Department d = new Department(); // Fill the properties of the new department object d.Name = txtName.Text; d.Budget = Convert.ToDecimal(txtBudget.Text); //save the new object to the database conn.Departments.Add(d); conn.SaveChanges(); //redirect to the departments page Response.Redirect("departments.aspx"); }