I have this code:
private void FillCombobox()
{
using (InventoryEntities c = new InventoryEntities(Properties.Settings.Default.Connection))
{
List<Customer> usepurposes = c.Customers.ToList();
DataTable dt = new DataTable();
dt.Columns.Add("id");
dt.Columns.Add("name");
foreach (Customer usepurpose in usepurposes)
{
dt.Rows.Add(usepurpose.id, usepurpose.name);
}
comboBox1.ValueMember = dt.Columns[0].ColumnName;
comboBox1.DisplayMember = dt.Columns[1].ColumnName;
comboBox1.DataSource = dt;
}
}
and I call this method in:
private void frmBillIn_Load(object sender, EventArgs e)
{
FillCombobox();
}
When I run my app, combobox will not display customers(items).
just display Model.Customer
What is the problem??
I tried many solution but non of them are working.