I am trying to save 4 dates into the DB after selecting from the ajax calendar control. Having problem saving some null dates into the DB.If all have dates it gets saved into db. If anydate is null I am getting error: FormatException: String was not recognized
as a valid DateTime. I tried tryparse and datetime.parse too.Nothing helped. Any suggestions? I am trying to hardcode the date for a workaround in place of null like this if (txtcalEstimatedFixDate == null) { txtcalEstimatedFixDate = 1/1/0001; } error:Cannot
implicitly convert type 'int' to 'string'
aspx:
<tr>
<td>
closedDate:
</td>
<td>
<asp:TextBox ID="txtcalClosedDate" runat="server"></asp:TextBox>
<asp:Image ID="Image2" runat="server" ImageUrl="~/images/cal.png" />
<asp:CalendarExtender ID="CalendarExtender2" TargetControlID="txtcalClosedDate" Format="dd/MM/yyyy" PopupButtonID="TextBox1" PopupPosition="Right" runat="server" />
</td>
</tr>
cs:
DateTime.ParseExact(txtcalOpenedDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture),
DateTime.ParseExact(txtcalClosedDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture)
DateTime.ParseExact(txtcalEstimatedFixDate.Text,"dd/MM/yyyy", CultureInfo.InvariantCulture),
DateTime.ParseExact(txtcalFixedDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture),