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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SqlConnection con = new SqlConnection(ConnectionString);
con.Open();
string rqt18 = "select * from SEMESTRE";
SqlCommand cm18 = new SqlCommand(rqt18, con);
SqlDataReader dr18 = cm18.ExecuteReader();
while (dr18.Read())
{
itm18 = new ListItem(dr18["LIBELLE_SEMESTRE"].ToString(), dr18["CODE_SEMESTRE"].ToString());
DropDownList1.Items.Add(itm18);
}
dr18.Close();
string sqlStatement = "SELECT * FROM MODULE WHERE CODE_SEMESTRE='" + DropDownList1.SelectedValue + "' ";
SqlCommand sqlCmd = new SqlCommand(sqlStatement, con);
SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
SqlDataReader dr1 = sqlCmd.ExecuteReader();
while (dr1.Read())
{
ListBox1.DataSource = dr1;
ListBox1.DataTextField = "LIBELLE_MODULE"; // the items to be displayed in the list items
ListBox1.DataValueField = "CODE_MODULE"; // the id of the items displayed
ListBox1.DataBind();
} dr1.Close();
SqlDataAdapter da = new SqlDataAdapter("SELECT CODE_MATIERE, LIBELLE_MATIERE FROM MATIERE where CODE_MODULE='" + ListBox1.SelectedValue + "'", con);
DataTable dt = new DataTable();
chkBoxEx.DataTextField = "LIBELLE_MATIERE";
da.Fill(dt);
chkBoxEx.DataSource = dt;
chkBoxEx.DataBind();
SqlCommand sqlcmd = new SqlCommand("select NUM_INSCRIPTION,NOM_PRENOM_ETUDIANT from [ETUDIANT]", con);
SqlDataAdapter adp = new SqlDataAdapter(sqlcmd);
DataSet ds = new DataSet();
adp.Fill(ds);
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
}
}
private void BindData()
{
SqlConnection con = new SqlConnection(ConnectionString);
SqlDataAdapter da = new SqlDataAdapter("SELECT CODE_MODULE, LIBELLE_MODULE FROM MODULE where CODE_SEMESTRE='" + DropDownList1.SelectedValue + "'", con);
DataTable dt = new DataTable();
da.Fill(dt);
ListBox1.DataSource = dt;
ListBox1.DataBind();
}
private string ConnectionString
{
get
{
string con = (@"maconnection");
return con;
}
}
protected void DrDoList2_SelectedIndexChanged(object sender, EventArgs e)
{
BindData();
} |