Exemple #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         using (var repo = new RepoGenre())
         {
             DropDownList1.DataSource = repo.GetAll().ToList();
             DropDownList1.DataBind();
         }
     }
 }
Exemple #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     //Si il s'agit d'un premier chargement
     if (!IsPostBack)
     {
         //Si il y a un valeur dans la variable PersonneId
         if (PersonneId != null)
         {
             //Je peux empiler plusieurs clauses using
             //Toutes ces variables seront effectives entre les { }
             using (var repog = new RepoGenre())
                 using (var repo = new RepoPersonne())
                 {
                     Personne p = repo.GetById(PersonneId.Value);
                     if (p != null)
                     {
                         Session["personne"] = p;
                         txtPrenom.Text      = p.Prenom;
                         txtNom.Text         = p.Nom;
                         txtEmail.Text       = p.Email;
                         ddlGenre.DataSource = repog.GetAll().ToList();
                         ddlGenre.DataBind();
                         ddlGenre.SelectedIndex = p.GenreId - 1;
                     }
                     else
                     {
                         Desactivation();
                     }
                 }
         }
         else
         {
             Desactivation();
         }
     }
 }