Réponse acceptée !
Salut,
Normalement on à une source de donnée par DropDownList avec une valeur et un texte.
Il faut définir les 2 propriétés : DataValueField et DataTextFiel de la DDL.
DDL1.DataSource = aff.DefaultView;
DDL1.DataTextField = "DatTable textfield";
DDL1.DataValueField = "DataTable valufield";
DDL1.DataBind();Dans ton cas tu peux essayer de mettre valeur et text pour la même colonne :
DDL1.DataValueField = aff.Columns[0].Caption;
DDL1.DataTextField = aff.Columns[0].Caption;
DDL2.DataValueField = aff.Columns[1].Caption;
DDL2.DataTextField = aff.Columns[1].Caption;
DDL3.DataValueField = aff.Columns[2].Caption;
DDL3.DataTextField = aff.Columns[2].Caption;
Sinon il y a une autre solution qui est de remplir à la main les DDL :
Tu fais un boucle sur les données et tu ajoutes un listItem de ce que tu veux :
for(int i=0; i<aff.Rows.count; i++)
{
DDL1.Items.Add( new ListItem( aff.Rows[i][0].ToString(), aff.Rows[i][0].ToString() ) );
DDL2.Items.Add( new ListItem( aff.Rows[i][1].ToString(), aff.Rows[i][1].ToString() ) );
DDL3.Items.Add( new ListItem( aff.Rows[i][2].ToString(), aff.Rows[i][2].ToString() ) );
}