?
Solved

Null date in pop up calender

Posted on 2005-03-14
6
Medium Priority
?
876 Views
Last Modified: 2013-11-28
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>
 
0
Comment
Question by:suran78
[X]
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
6 Comments
 
LVL 28

Assisted Solution

by:iboutchkine
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:

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
 
LVL 10

Accepted Solution

by:
EBatista earned 800 total points
ID: 13540275
0
 

Author Comment

by:suran78
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
        Else
            Return theDate
        End If

    End Function
0
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

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

Expert Comment

by:EBatista
ID: 13559365
glad to help
0
 

Author Comment

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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

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