I have a table named Constituent which contains a field called ClergyType which is an uniqueidentifer,
I have another table named BaseCode which contains a field called Oid which is an uniqueidentifer and will match the ClergyType in the table Constituent.
Table BaseCode also contains a field called Description (Nvarchar) and another field called Code (Nvarchar).
I wish to build a list to use as a datasource for a lookupedit that will contain all the Descriptions from BaseCode table based on the value of BaseCode.Code being 16.
And I need the first entry shown to be the Description tied to the the ClergyType in my current record of Constituent.
And the edit value to be the ClergyType field in my current Constituent record.
The following code works as far as loading the dropdown with all possible values, but it does not load the current Constituent record at top of list, the lookupedit
is blank when the screen loads, but with the dropdown button you do see the list, but nothing is selected on it.
lookUpEditClergyType.DataBindings.Add("EditValue", Constituent, "ClergyType");
UnitOfWork unitOfWork4 = new UnitOfWork();
var clt = new XPCollection<ClergyTypeCode>(unitOfWork4);
lookUpEditClergyType.Properties.DataSource = clt;
lookUpEditClergyType.Properties.DisplayMember = "ClergyType";
lookUpEditClergyType.Properties.ValueMember = "ClergyType";
Hi,
From what I gather, the Constituent persistent class has the ClergyType property, to which you wish to bind LookUpEdit's edit value. In its turn, you use XPCollection of the ClergyTypeCode objects as a data source for LookUpEdit although in your post, you are talking about the BaseCode table. So, what table do you use for LookUpEdit? ClergyTypeCode or BaseCode?
You've mentioned that you have the Oid field in the BaseCode table. You said that this field corresponds to the ClergyType field from the Constituent table. From this, I understand that these fields have the same data types and identical values. Correct me if I am wrong. Then, in your code, I see that you set the DisplayMember and ValueMember properties to ClergyType. Do you have the ClergyType field in the BaseCode or ClergyTypeCode table, i.e. in LookUpEdit's data source? If you wanted to show a list of descriptions, it is unclear why you set the DisplayMember property to ClergyType.
The DisplayMember property should be set to a field name from LookUpEdit's data source whose values should be used as display values. The ValueMember property should be set to a field name from LookUpEdit's data source whose values should be used as real edit values. If you need to bind the LookUpEdit.EditValue property to the ClergyType property of the Constituent object, the ValueMember field data type should correspond to the ClergyType field type. I recommend that you review the LookUpEdit - Text disappears after moving focus from the editor KB article for more information in this regard.
If this information is not helpful, please create a small sample to illustrate the issue and send it to us for investigation.
I look forward to your response.