Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combobox data binding
Message
From
04/03/2005 09:29:16
 
 
To
All
General information
Forum:
ASP.NET
Category:
Forms
Title:
Combobox data binding
Environment versions
Environment:
C# 1.1
OS:
Windows XP SP2
Network:
Windows NT
Database:
MS SQL Server
Miscellaneous
Thread ID:
00992721
Message ID:
00992721
Views:
61
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
Next
Reply
Map
View

Click here to load this message in the networking platform