I have a nullable date in my database. I am connecting to it with a LinqDataSource, and binding with a FormView. It allows you to place dates fine, but if you remove the date I need it to insert the null value to the db. It is instead throwing an exception.
<asp:TextBox ID='TxtStartDate' runat='server' Text='<%# Bind('StartDate', '{0:MM/dd/yyyy}') %>' />
Works fine if you place a date in it, but if you delete the date out of it and save, you get System.Data.SqlTypes.SqlTypeException: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM. How do I make it send null?
I don’t know if it was the best way, but I fixed it by subscribing to the FormView Updating event and placed the following code: