Datagrid

dev_titanium Messages postés 1 Date d'inscription vendredi 24 mars 2006 Statut Membre Dernière intervention 24 mars 2006 - 24 mars 2006 à 15:09
Lutinore Messages postés 3246 Date d'inscription lundi 25 avril 2005 Statut Membre Dernière intervention 27 octobre 2012 - 24 mars 2006 à 19:40
bonjour , pouriez vous m'aider a trouve une solution ou me donner un lien pour trouve la solution de mon probleme

lorsque je fais dans mon databgrid qui est lie a un bd

DataGrid2.DataSource=d.Tables["client"];

j'ai tous les champs qui s'affiche et moi je n'ai besoin que de 2 chmaps comment faire
merci

2 réponses

Lutinore Messages postés 3246 Date d'inscription lundi 25 avril 2005 Statut Membre Dernière intervention 27 octobre 2012 41
24 mars 2006 à 19:00
Salut, tu peux limiter ta requête SQL, sinon voilà comment je fais :

DataGridTextBoxColumn columnProductName = new DataGridTextBoxColumn( );
columnProductName.MappingName = "ProductName"; // Nom de la colonne.
columnProductName.HeaderText = "Nom du Produit";

DataGridTextBoxColumn columnUnitPrice = new DataGridTextBoxColumn( );
columnUnitPrice.MappingName = "UnitPrice"; // Nom de la colonne.
columnUnitPrice.HeaderText = "Prix à l'unité";

DataGridTableStyle style = new DataGridTableStyle( );
style.MappingName = "Products"; // Nom de la table.
style.GridColumnStyles.AddRange
(
new DataGridColumnStyle[ ]
{
columnProductName,
columnUnitPrice
}
);


DataGrid dg = new DataGrid( );
dg.TableStyles.Add( style );
dg.DataSource = ds;
dg.DataMember = "Products"; // Nom de la table.
0
Lutinore Messages postés 3246 Date d'inscription lundi 25 avril 2005 Statut Membre Dernière intervention 27 octobre 2012 41
24 mars 2006 à 19:40
L'exemple précédent c'est pour le colonnes mais si ça se trouve c'est les lignes que tu veux filter, pour faire ça j'aurais utilisé un DataView :

DataView dv = new DataView( ds.Tables[ "Products" ] ); // Nom de la table.
dv.RowFilter = "ProductName='Chai'OR ProductName='Ikura'"; // comme un WHERE.


DataGrid dg = new DataGrid( );
dg.DataSource = dv;
0
Rejoignez-nous