Welcome Guest Search | Active Topics | Sign In | Register

Datepicker - DBNull conversion Options
Paul Creedy
Posted: Friday, August 3, 2007 6:23:03 AM
Rank: Advanced Member
Groups: Member

Joined: 6/5/2007
Posts: 76
When using the datepicker control to edit and existing date/time field and the database value is null, I get an error.

Is there a way to take into account that some date/time fields when being edited may not already have an existing date/time?

Conversion from type 'DBNull' to type 'Date' is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Conversion from type 'DBNull' to type 'Date' is not valid.

Source Error:


Line 90: <asp:TemplateField HeaderText="Ends" SortExpression="event_enddate">
Line 91: <EditItemTemplate>
Line 92: <eo:DatePicker ID="DatePicker3" runat="server" ControlSkinID="None" DayCellHeight="16"
Line 93: DayCellWidth="21" DayHeaderFormat="FirstLetter" DisabledDates="" GridLineColor="207, 217, 227"
Line 94: GridLineFrameVisible="False" GridLineVisible="True" PickerFormat="dd/MM/yyyy HH:mm"

eo_support
Posted: Friday, August 3, 2007 6:27:32 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,095
Hi Paul,

You won't be able to do that. The error is actually thrown out by ASP.NET pager compiler. The solution is to use what you have already found ---- SelectedDataString property.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.