Linq sql data binding with winobs combobox

I am trying to link ComboxBox with an external keymap. I know that on cannot bind to the actual foreign key, SomeTableClassFK (throws a LinqSql exception when FK is already set). So I am binding to an FK object, SomeTable, referencing the SelectedItem property of the ComboBox.

SomePrimaryTable
  SomeTableClassFK ---> SomeTableClass.PK
  SomeTable --------> SomeTableClass

this.aComboBox.DataBindings.Add (new System.Windows.Forms.Binding ("SelectedItem", this.somePrimaryTableBindingSource, "PendingReason", false));

This does not work. The ComboBox always binds the FK object to the first item in its list.

Any ideas?

0


a source to share


2 answers


Ok ... The problem was related to the quirky behavior of the winform. Obviously there is no guarantee that OnLoad for a custom control will not be called more than once. As a consequence, the two tables in use (see diagram above) were loaded from different DataContexts. Splat !!



0


a source


I don't know exactly in which post, but I remember scottgui came up with a solution to this issue in the linq lineup ... perhaps to try and find it:

http://weblogs.asp.net/scottgu/archive/2007/09/07/linq-to-sql-part-9-using-a-custom-linq-expression-with-the-lt-asp-linqdatasource- gt-control.aspx



amuses

0


a source







All Articles