Null date in pop up calender

Posted on 2005-03-14
Medium Priority
Last Modified: 2013-11-28

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">
<ASP:Label Text='<%# DataBinder.Eval(Container.DataItem, "disabled_date") %>' runat="server" ID="Label10" />
<ew:CalendarPopup id="Calendarpopup3" runat="server" ShowGoToToday="True" nullable = "true" SelectedDate='<%#
DataBinder.Eval(Container.DataItem, "disabled_date") %>'>
Question by:suran78
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 28

Assisted Solution

iboutchkine earned 200 total points
ID: 13537495
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:


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

LVL 10

Accepted Solution

EBatista earned 800 total points
ID: 13540275

Author Comment

ID: 13558694
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
            Return theDate
        End If

    End Function
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.


Author Comment

ID: 13558727
Got it resolved.  Just removed friend from the function.   Thanks
LVL 10

Expert Comment

ID: 13559365
glad to help

Author Comment

ID: 13559393
I have 3 more question open.  Please reply if interested

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog, I will share you some basic tips for content marketing and to rank your website on Google.
We aren’t perfect, just like everyone else.  Check out the email errors our community caught and learn the top errors every email marketer should avoid.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question