DataFormComboBoxField: ForeignKeyReferenceAlreadyHasValueException

2 posts, 0 answers
  1. Gerrit
    Gerrit avatar
    1 posts
    Member since:
    Feb 2012

    Posted 24 Oct 2012 Link to this post


    we currently have the following problem:

    There is a table named ST_Classification and one named ST_Address, which have the following relationship:
    ST_classification.PK_classification -> ST_Address.FK_classification

    In a WPF-Application there is a DataFormComboBoxField which is populated with data from the ST_Classification table.
    The moment the value is set to a new one an exception is thrown:
    System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException was unhandled by user code
    Message=Operation is not valid due to the current state of the object.

    This is code in the xxx.designer.cs where the exception is thrown:
    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_FK_classification", DbType="BigInt", UpdateCheck=UpdateCheck.Never)]
            public System.Nullable<long> FK_classification
                    return this._FK_classification;
                    if ((this._FK_classification != value))
                        if (this._ST_classification.HasLoadedOrAssignedValue)
                            throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
                        this.SendPropertyChanging(); // <--- Exception is thrown!
                        this._FK_classification = value;

    This is the XAML-code for the DataFormComboBoxField:
    <telerik:RadDataForm x:Name="RDF_ST_Addresse" ItemsSource="{Binding Items, ElementName=RG_ST_Partner}"
    AddedNewItem="RDF_ST_Addresse_AddedNewItem" >
    <telerik:DataFormComboBoxField DataMemberBinding="{Binding FK_classification, Mode=TwoWay}"  Name="DFCMB_classification"
    Label="Klassifikation" IsReadOnly="False"
    DisplayMemberPath="classification" Initialized="DFCMB_classification_Initialized" />

    Here is the codeBehind for DataFormComboBoxField:
    private void DFCMB_classification_Initialized(object sender, EventArgs e)
                    ((DataFormComboBoxField)sender).ItemsSource = from p in goDCAddach.ST_classifications orderby p.classification     select p ;

     Thanks for any help in advance.


  2. Ivan Ivanov
    Ivan Ivanov avatar
    1201 posts

    Posted 24 Oct 2012 Link to this post

    Hello Gerrit,

    Would it be possible for you to send us a simple repro project via a support ticket, so that we could debug it on our side?

    Kind regards,
    Ivan Ivanov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top