Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Combobox data binding
Message
De
04/03/2005 09:29:16
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Titre:
Combobox data binding
Versions des environnements
Environment:
C# 1.1
OS:
Windows XP SP2
Network:
Windows NT
Database:
MS SQL Server
Divers
Thread ID:
00992721
Message ID:
00992721
Vues:
60
I'm new to .NET and I'm trying to bind a combobox to a DataTable without success. I don't receive any error message, but the combobox show up empty. Here is the code:
private void ListeEntrees_Load(object sender, System.EventArgs e)
{
   Table table = new Table ();
   dtClient = table.getTable ("Client");   // Get the Client table in a DataTable
   cboClient.DataSource = dtClient;   // Bind the combobox to the DataTable
   cboClient.DisplayMember = "Client";   // Name of the field to display
   cboClient.ValueMember = "PK_Client";   // Primary key
}
The only way I can get this to work is to scan through the DataTable and fill up the combobox with the Add method. Not very pretty IMO and I don't know how to bind the primary key to the values that way.

Any ideas?

TIA
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform