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
|
private void Page_Load(object sender, System.EventArgs e)
{
// Placer ici le code utilisateur pour initialiser la page
Remplir_Combo();
this.DataGrid1.DataBind();
this.TextBox1.DataBind();
this.TextBox2.DataBind();
this.TextBox3.DataBind();
this.TextBox4.DataBind();
}
//--------------------------------------------------------//
//------Remplit le combo avec le contenu de la table-----//
//------------------------------------------------------//
void Remplir_Combo()
{
this.DropDownList1.Items.Clear(); //---On efface tout ce qu'elle contient---//
this.daLiens.Fill(this.ds,"tb_LIENS");
this.DropDownList1.Items.Add("");
for(int j=0;j<this.ds.tb_LIENS.Count;j++)this.DropDownList1.Items.Add(this.ds.tb_LIENS[j]["IDLien"].ToString());
this.DropDownList1.DataBind();
}
//------------------------------------------------------//
//------------Effectue le filtre sur le datagrid-------//
//----------------------------------------------------//
private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
string IDLIEN="";
if(this.DropDownList1.Items[this.DropDownList1.SelectedIndex].ToString()=="")IDLIEN="IDLIEN";
else IDLIEN=this.DropDownList1.Items[this.DropDownList1.SelectedIndex].ToString();
this.sqlSelectCommand1.CommandText="SELECT * FROM tb_LIENS WHERE IDLIEN="+IDLIEN;
this.Connection.Open();
this.daLiens.Fill(this.ds.tb_LIENS);
this.Connection.Close();
this.DataGrid1.DataBind();
}
} |