Null date in pop up calender

Experts,

I have a datagrid with date field.  I displaying this date field by using calender pop up from Excentrics World.  When the date field is not null, it's working fine, but if the date field is null I am getting this error:
I am not looking for another calender pop up.  I am very happy with this tool, all I need to do is allow the null date to open in datagrid edit mode as empty and let the user enter a new date.  please help.

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

Source Error:

Line 77:       </ItemTemplate>
Line 78: <EditItemTemplate>
Line 79: <ew:CalendarPopup id="Calendarpopup3" runat="server" ShowGoToToday="True" nullable = "true" SelectedDate='<%#
Line 80: DataBinder.Eval(Container.DataItem, "disabled_date") %>'>
Line 81: </ew:CalendarPopup>

Here is the datagrid code:

asp:TemplateColumn HeaderText="Disabled Date">
<ItemTemplate>
<ASP:Label Text='<%# DataBinder.Eval(Container.DataItem, "disabled_date") %>' runat="server" ID="Label10" />
</ItemTemplate>
<EditItemTemplate>
<ew:CalendarPopup id="Calendarpopup3" runat="server" ShowGoToToday="True" nullable = "true" SelectedDate='<%#
DataBinder.Eval(Container.DataItem, "disabled_date") %>'>
</ew:CalendarPopup>
</EditItemTemplate>
</asp:TemplateColumn>
 
suran78Asked:
Who is Participating?
 
EBatistaConnect With a Mentor Commented:
0
 
iboutchkineConnect With a Mentor Commented:
There is no easy way to handle null values with DateTimePicker control shipped
with .net.
However, I have heard that the customized control by Lutz Roeder supports null
values. It is a free download that you might want to download and test out in
your project.

Here is the link to his site:

http://www.aisto.com/roeder/dotnet
=============================================


Here is another example . It is in C#, but you will get an idea

http://www.codeproject.com/cs/miscctrl/Nullable_DateTimePicker.asp
0
 
suran78Author Commented:
I tried by creating a setdate function, but I am getting this error at line 58:

Compiler Error Message: BC30390: 'chlorAlkali.createcells.Private Function SetDate(theDate As Object) As Object' is not accessible in this context because it is 'Private'.

Source Error:

Line 56:                                     </ItemTemplate>
Line 57:                                     <EditItemTemplate>
Line 58:                                     <ew:CalendarPopup id="Calendarpopup3" runat="server" SelectedDate='<%# SetDate(Container.DataItem("disabled_date")) %>'>
Line 59:                                           </ew:CalendarPopup>
Line 60:                                     </EditItemTemplate>
 
Added this function in code behind:
Friend Function SetDate(ByVal theDate As Object)

        If theDate Is DBNull.Value Then
            Return DateTime.MinValue
        Else
            Return theDate
        End If

    End Function
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
suran78Author Commented:
Got it resolved.  Just removed friend from the function.   Thanks
0
 
EBatistaCommented:
glad to help
0
 
suran78Author Commented:
I have 3 more question open.  Please reply if interested
0
All Courses

From novice to tech pro — start learning today.