Exemplo n.º 1
0
        protected void getStudents()
        {
            var connection = new StudentEntities();
            var Students   = from d in connection.Students select d;

            //Save to DB
            gridStudents.DataSource = Students.ToList();
            gridStudents.DataBind();
        }
Exemplo n.º 2
0
        /**
         * Save Button Was Clicked
         */
        protected void btnSave_Click(object sender, EventArgs e)
        {
            var connection = new StudentEntities();

            Student s = new Student();

            s.FirstMidName   = txtFirstName.Text;
            s.LastName       = txtLastName.Text;
            s.EnrollmentDate = DateTime.Parse(txtEnrollmentDate.Text);

            //Save to DB
            connection.Students.Add(s);
            connection.SaveChanges();

            //Redirect
            Response.Redirect("students.aspx");
        }