Changing Foreign Key using LINQ to SQL and UltraCombo

Jason Beres / Saturday, February 28, 2009

Scenario:

  1. You are using a ultraComboEditor on a detailview showing an order object.
  2. You using Linq for Sql, and I am having a Order and a OrderState objects that I would like to bind together.

 

On the detailView for the Order object I would like to have an UltraComboEditor, in which it is possible to set the state of the order. The datasource of the UltraComboEditor would be a bindingSource containing OrderState objects.  Normally you would setup the datasource bind the UltraComboEditor using the foreignKey id on the order object, and set the ValueMember of the UltraComboEditor to the primaryKey of the OrderState.

In Linq for SQL it is not possible to change the foreignKey Id on the Order (OrderStateId) object if the corresponding OrderStatus object already has been loaded, but using the Windows Forms ComboBox (or is it UltraComboEditor?) it is possible to bind through the SelectedItem property.

Set the ValueMember to Infragistics.Win.BindableValueList.USE_LISTOBJECT_AS_VALUEMEMBER.