protected void getStudents()
        {
            // connect to db
            var conn = new ContosoEntities();

            // run the query using LINQ
            var Students = from s in conn.Students
                           select s;

            // display query result in gridview
            grdStudents.DataSource = Students.ToList();
            grdStudents.DataBind();
        }
        protected void getDepartments()
        {
            // connect to db
            var conn = new ContosoEntities();

            // run the query using LINQ
            var Departments = from d in conn.Departments
                              select d;

            // display query result in gridview
            grdDepartments.DataSource = Departments.ToList();
            grdDepartments.DataBind();
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //connect the db
            var conn = new ContosoEntities();

            //use the Department class to create a new Department object from department.cs
            Department d = new Department();

            //fill the properties of the new department object
            d.Name   = txtName.Text;
            d.Budget = Convert.ToDecimal(txtBudget.Text);

            //save a new object to db
            conn.Departments.Add(d);
            conn.SaveChanges();

            //redirect to the department page
            Response.Redirect("departments.aspx");
        }
        // When save button is clicked connect to DB and save the values to DB
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //connect the db
            var conn = new ContosoEntities();

            //use the Student class to create a new Student object from student.cs
            Student s = new Student();

            //fill the properties of the new student object
            s.FirstMidName   = txtFirstName.Text;
            s.LastName       = txtLastName.Text;
            s.EnrollmentDate = Convert.ToDateTime(eTxtDate.Text);

            //save a new object to db
            conn.Students.Add(s);
            conn.SaveChanges();

            //redirect to the department page
            Response.Redirect("students.aspx");
        }