Réponse acceptée !
oki merci beaucoup .
J'avais trouvé quelques réponses sur le net à mes questions , voici le code réponse :
SqlDataReader DR = sqlCommand.ExecuteReader();
int PK_Mobile;
bool Active;
while(DR.Read())
{
PK_Mobile = DR.GetInt32(0);
//Création des cellules
TableCell Cell_Num = new TableCell();
Cell_Num.Text = DR.GetString(1);
TableCell Cell_Nom = new TableCell();
Cell_Nom.Text = DR.GetString(2);
TableCell Cell_Prenom = new TableCell();
Cell_Prenom.Text = DR.GetString(3);
Active = DR.GetBoolean(4);
CheckBox Check_Active = new CheckBox();
Check_Active.Checked = Active;
Check_Active.ID = "Check_Active_"+PK_Mobile.ToString();
TableCell Cell_Active = new TableCell();
Cell_Active.Controls.Add(Check_Active);
Button Button_Remove = new Button();
Button_Remove.Text = "Supprimer";
Button_Remove.ID = "Button_Remove_"+PK_Mobile.ToString();
//Ajout d'un événement sur le boutton
Button_Remove.Click += new EventHandler(Button_Remove_Click);
TableCell Cell_Button = new TableCell();
Cell_Button.Controls.Add(Button_Remove);
//Création de la ligne
TableRow Line = new TableRow();
Line.Cells.Add(Cell_Num);
Line.Cells.Add(Cell_Nom);
Line.Cells.Add(Cell_Prenom);
Line.Cells.Add(Cell_Active);
Line.Cells.Add(Cell_Button);
//Insertion dans le tableau
MobilesTable.Rows.Add(Line);
}
et le code pour la fonction sur un clic de bouton :
private void Button_Remove_Click(object sender, System.EventArgs e)
{
Button Clicked_Button = (Button)sender;
ClickedLabel.Text ="Vous venez de choisir le PK= " + Clicked_Button.ID.ToString();
}
Voila voila
Billou_13
Bask En Force
