1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
namespace memoire
{
public partial class frequentation : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DropDownList1.Items.GetEnumerator();
String con = "Data source=localhost;Initial catalog=concours;uid=mwizero;pwd=mwizero";
SqlConnection connection = new SqlConnection(con);
String req = " select idcandidat,Code_candidat,Nom_candidat,Prenom_candidat from candidat ";
connection.Open();
SqlCommand reqcom = new SqlCommand(req, connection);
SqlDataReader der = reqcom.ExecuteReader();
List(Of candidat) maListe = new List(Of candidat);
Candidat currenrObject;
while (der.Read())
{
currentObject = new Candidat;
currentObject.Id = der.GetInt32(0);
currentObject.Code = der.GetString(1);
currentObject.Nom = der.GetString(2);
currentObject.Prenom = der.GetString(3);
maListe.Add(currentObject);
}
connection.Close();
DropDownList1.DataSource = maListe;
DropDownList1.DataValueField = "Id";
DropDownList1.DataTextField = "Code";
}
Private class Candidat
{
int Id;
string Code;
string Nom;
string Prenom;
// le code de génération de ta classe
} |
Partager