In brief, LINQ to SQL compares the original value and new value and generates SQL code to update the original object.Since the original object was modified by the Form View, it will never be found by SQL and no update will occur!This Form View behavior can be problematic when we we need the original object and the modified object to perform an update with conflict detection (see LINQ to SQL example below).Note that Conflict Detection is set to Compare All Values in the Object Data Source.
As, you can see in the code above that the Header Template simply contains a simple Label which display the Text "User Details". I have marked the Header Template with a red circle to make it clear. As, you can see from the screenshot above that Item Template displays the First Name, Last Name and Address.While there are other techniques you can use with Linq to SQL to avoid the issue above, the point of this post is to show how the Form View handles null values.The workaround is to subscribe to the Form View Item Updating event and look for string.empty New Values and set those to null instead.Since, there are several Link Buttons inside the Form View control the command Name can be used to distinguish between different events generated inside the Form View through Link Buttons.Take a look at the code below which switches the Form View control between different modes. Command Name property is "Edit" the Form View mode is changed to Form View Mode. Command Name is "Cancel" then it changes to the "Read Only" mode. Command Name is Update I do not switch to any mode because on update I need to retrieve the values from the Text Boxes and send them to the database to update the data.