private void load_GridView() { GridViewEmploye.DataSource = (from emp in dbContext.employees select new { emp.employeID, emp.firstName, emp.lastName, emp.email, emp.phone, emp.departement.Description } ).ToList(); GridViewEmploye.DataBind(); }
protected void BtCherche_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(TBZoneCherche.Text)) { switch (RBSearch.SelectedValue) { case "departement": GridViewEmploye.DataSource = (from emp in dbContext.employees where emp.departement.Description == TBZoneCherche.Text select emp).ToList(); break; case "lastname": GridViewEmploye.DataSource = (from emp in dbContext.employees where emp.lastName == TBZoneCherche.Text select emp).ToList(); break; default: break; } GridViewEmploye.DataBind(); } }