I have asp.net page with a linqdatasource, it use the OnUpdating method.
OnUpdating="Entity_OnUpdating"
In code-behind:
protected void Entity_OnUpdating(object sender, LinqDataSourceUpdateEventArgs e)
{
MyClass objEntity = (MyClass)e.NewObject;
if (expression)
MyClass.InfoID = Guid.NewGuid();
else
MyClass.InfoID = null;
}
If the expression is false, and MyClass.InfoID was not null before update, MyClass.InfoID not changes to null.
UPD:
MyClass has two fields:
1) ID - primary key,
2) InfoID - nullable foreign key.
Do you know, why it work like this?
What does your MyClass object looks like? Without looking at the object, I can guess that the property 'ID' is either listed as Primary key, Foreign Key, or simply does not allow nulls.