我遇到一个问题,LookUpEdit
的值未在DataBindings
添加的DataSource中更新。我所做的是我对表单进行LookUpEdit
控制并设置了LookUpEdit DataSource,Value和DisplayMember。然后我添加了DataBindings
第二个BindingSource,其中LookUpEdit中的更改值未在第二个BindingSource中更新:
BindingSource bindingSource1 = // here i get IQueryable
BindingSource bindingSource2 = // here i get IQueryable where one field from bindingSource1 is set as foreign key
lookUpEdit1.Properties.DataSource = bindingSource1.
lookUpEdit1.Properties.ValueMember = "Id";
lookUpEdit1.Properties.DisplayMember = "Name";
lookUpEdit1.DataBindings.Add("EditValue", bindingSource2, "fk_id", true, DataSourceUpdateMode.OnPropertyChanged);
有时候我会System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException was unhandled too
。第二个BindingSource设置为GridControl的DataSource,即GridView。
答案 0 :(得分:0)
设置gridView1.OptionsBehavior.CacheValuesOnRowUpdating = CacheRowValuesMode.Disabled。