Exemple #1
0
        /**
         * <summary>
         * This method gets the student from the DB.
         * </summary>
         *
         * @method GetStudents
         * @return {void}
         */
        protected void GetStudents()
        {
            // connect to EF
            using (DefaultConnection db = new DefaultConnection())
            {
                // query the students table using EF and LINQ
                var Students = (from allStudents in db.Students
                                select allStudents);

                // bind the result to the GridView
                StudentsGridview.DataSource = Students.ToList();
                StudentsGridview.DataBind();
            }
        }
        /**
         * <summary>
         * This method gets the student from the DB.
         * </summary>
         * 
         * @method GetStudents
         * @return {void}
         */
        protected void GetStudents()
        {
            // connect to EF
            using (DefaultConnection db = new DefaultConnection())
            {
                string SortString = Session["SortColumn"].ToString() + " " + Session["SortDirection"].ToString();

                // query the students table using EF and LINQ
                var Students = (from allStudents in db.Students
                                select allStudents);

                // bind the result to the GridView
                StudentsGridview.DataSource = Students.AsQueryable().OrderBy(SortString).ToList();
                StudentsGridview.DataBind();
            }
        }