Asp.net Date Binding Issue with Nulls
- by Matthew Kruskamp
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?