2012-06-26 176 views
1

样本组合框:组合框在DataGrid中(C#WPF)

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

MySQL的Web服务器

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; 

所以我建一个表上SOURSE数据,所有的数据是存在的,除了中,Status是空的,为什么?

+0

没有大写问题? WPF是区分大小写的状态还是状态? – MBen

+0

好吧 – user1478466

+2

有点奇怪你将SelectedItem和ItemsSource绑定到同一个属性。 ItemsSource应该绑定到一个集合,并将SelectedItem绑定到单个元素。否则,我们需要更多的细节。我现在只是在猜测 – MBen

回答