コード例 #1
0
        private void SelectByFirstLast(string last, string first)
        {
            IBStudentsDataContext db = new IBStudentsDataContext();

            var results = from p in db.IB_Students
                          where p.LastName == last &&
                          p.FirstName == first
                          orderby p.ClassOf
                          select new
            {
                p.StudentNo,
                p.LastName,
                p.FirstName,
                p.ClassOf
            };

            if (results.FirstOrDefault() != null)
            {
                gdResult.DataSource = results;
                gdResult.DataBind();
                lblMessage.Text = "Click select to view details !";
            }
            else
            {
                lblMessage.Text = "No student found !";
            }
        }
コード例 #2
0
        private void SelectAllYears()
        {
            IBStudentsDataContext db = new IBStudentsDataContext();

            var results = from p in db.IB_Students
                          orderby p.ClassOf, p.LastName, p.FirstName
                select new  {
                p.StudentNo,
                p.LastName,
                p.FirstName,
                p.ClassOf
            };

            if (results.FirstOrDefault() != null)
            {
                gdResult.DataSource = results;
                gdResult.DataBind();
                lblMessage.Text = "Click select to view details !";
            }
            else
            {
                lblMessage.Text = "No student found !";
            }
        }