protected void BtCherche_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(TBZoneCherche.Text)) { switch (RBSearch.SelectedValue) { case "Description": GridViewDepartement.DataSource = (from dep in dbContext.departements where dep.Description == TBZoneCherche.Text select dep).ToList(); break; case "Ville": GridViewDepartement.DataSource = (from dep in dbContext.departements where dep.Ville == TBZoneCherche.Text select dep).ToList(); break; default: break; } GridViewDepartement.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { GridViewDepartement.DataSource = (from dep in dbContext.departements select dep).ToList(); GridViewDepartement.DataBind(); }