user1478466
user1478466

Reputation: 29

ComboBox in DataGrid (c# wpf)

sample combobox:

<DataGridComboBoxColumn
Header="Status"
SelectedItemBinding="{Binding status}"
ItemsSource="{Binding status}"
Width="98.8"
/>

sourse data on mysql web server

MySqlCommand cmd = new MySqlCommand("select id,user_name,user_phone,user_email,payment_method,amount,user_comment,delivery_city,delivery_address,status from `request`", conn);
DataTable dt = new DataTable();
dt.Load(cmd.ExecuteReader());
dataGrid1.ItemsSource = dt.DefaultView;

so I build a table, all data is there except, the Status is empty, why?

Upvotes: 1

Views: 335

Answers (1)

paparazzo
paparazzo

Reputation: 45106

The ItemsSource needs to be a collection. See the bottom of this link if you need an enum collection. http://msdn.microsoft.com/en-us/library/system.windows.controls.datagridcomboboxcolumn.aspx

If the collection is dynamic then you need a class with a property that returns a collection.

Upvotes: 2

Related Questions