Hi,
I am getting this exception and need help badly.
Scenario:
I have a table Users. Binded this entity to GridView.
I have one more table Roles. Id of Roles is foreignKey RoleID in Users.
Binded this as a combo-box column in GridView
this.radGridView.Columns.Add(new GridViewComboBoxColumn()
{
ItemsSourceBinding = new System.Windows.Data.Binding("Roles") { Source = this.DataContext },
DataMemberBinding = new System.Windows.Data.Binding("Role") ,
DisplayMemberPath = "Role",
SelectedValueMemberPath = "RoleID",
Header = "User-Role",
FilterMemberPath="RoleReconUserRoles.Role",
IsReadOnly=false,
Name = "gridView"
});
It works fine. But, when I change the item in the combo-box, and try to commit, it changes back to the original value because I get this ForeignKeyReferenceAlreadyHasValueException exception in the entity.
/// <summary>
/// Gets or sets the Role column value.
/// </summary>
[System.Data.Linq.Mapping.Column(Name = "Role", Storage = "_role", DbType = "int NOT NULL", IsPrimaryKey = true, CanBeNull = false, UpdateCheck = System.Data.Linq.Mapping.UpdateCheck.Never)]
[System.Runtime.Serialization.DataMember(Order = 3)]
[System.CodeDom.Compiler.GeneratedCode("CodeSmith", "6.0.0.0")]
public int Role
{
get { return _role; }
set
{
if (_role != value)
{
if (_roleReconUserRoles.HasLoadedOrAssignedValue)
{
throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
}
OnRoleChanging(value);
SendPropertyChanging("Role");
_role = value;
SendPropertyChanged("Role");
OnRoleChanged();
}
}
}
Any help is appreciated!
Thanks in advance,
Sindhu