I have a textbox in a formview that gets its data from a linqdatasource which is used to enter a date:
<SP:TextBox ID = "StartDate"
Type = "Date"
Runat = "server"
Text = '<%# Bind("StartDate", "{0:yyyy-MM-dd}") %>' />
It works fine, except when StartDate is a null value in the database. Then the StartDate textbox is empty which is correct, but when the empty field is saved back to the database the date 0001-01-01 is stored instead of a null value which is wrong. How can I detect this scenario and turn the empty string into a null value before it is saved?
The solution is to add parameters for the nullable columns and set ConvertEmptyStringToNull to true:
http://connect.microsoft.com/VisualStudio/feedback/details/296161/linqdatasource-and-null-column-values