如何获得与实体绑定的DevExpress WPF ComboEdit的选定值?

时间:2013-05-16 06:41:13

标签: wpf entity-framework combobox wpf-controls devexpress

我在我的WPF应用程序中有一个ComboEdit控件,该控件由名为“Contacts”的实体绑定。现在我想要选择ComboEdit的值。

<dxe:ComboBoxEdit Name="ddlFirstName" HorizontalAlignment="Left" Margin="125,24,0,0" VerticalAlignment="Top" Width="140" SelectedIndexChanged="ddlFirstName_SelectedIndexChanged"/>

protected void BindAllDropdown()
    {
        ddlFirstName.ItemsSource = BLL.GetAllContacts();
        ddlFirstName.DisplayMember = "FirstName";
        ddlFirstName.ValueMember = "ContactID";


        ddlLastName.ItemsSource = BLL.GetAllContacts();
        ddlLastName.DisplayMember = "LastName";
        ddlLastName.ValueMember = "ContactID";


    }

我正在尝试使用以下方法获取所选索引更改事件的选定值:

string contid = ddlFirstName.SelectedItem.ToString();

这会返回整个实体,因此无法获取所选值。如何获得所选值?

帮助表示感谢! 谢谢!

1 个答案:

答案 0 :(得分:2)

使用ComboBoxEdit.EditValue属性:

void ComboBoxEdit_EditValueChanged(object sender, EditValueChangedEventArgs e) {
    string contid = cb.EditValue.ToString();
}