Calendar control and Null dates issue

Discussion in 'ASP .Net' started by Craig Buchanan, Aug 17, 2007.

  1. I have embedded an asp:Calendar control into the EditItemTemplate of
    GridView column. I have set the SelectedDate='<%# Bind("Finished") %>'
    VisibleDate='<%# Eval("Finished") %>', to the AccessDataSource's 'Finished'
    column (a Date type).

    The control correctly binds to the column if the date isn't null. If the
    column is null, I get an error that reads:

    Conversion from type 'DBNull' to type 'Date' is not valid.

    What am I missing here? Is there an easy fix?

    Thanks,

    Craig Buchanan
    Craig Buchanan, Aug 17, 2007
    #1
    1. Advertising

  2. Here you have an article that explains how to avoid this in PreRender:

    http://www.c-sharpcorner.com/Upload...ol11222005054337AM/ASPNetCalendarControl.aspx

    Some other guys tell to extend the calendar control in order to handle null
    values in the get/set property of the calendar control:

    http://forums.asp.net/p/1046084/1468000.aspx

    HTH
    Braulio


    /// ------------------------------
    /// Braulio Diez
    ///
    /// http://www.tipsdotnet.com
    /// ------------------------------




    "Craig Buchanan" wrote:

    > I have embedded an asp:Calendar control into the EditItemTemplate of
    > GridView column. I have set the SelectedDate='<%# Bind("Finished") %>'
    > VisibleDate='<%# Eval("Finished") %>', to the AccessDataSource's 'Finished'
    > column (a Date type).
    >
    > The control correctly binds to the column if the date isn't null. If the
    > column is null, I get an error that reads:
    >
    > Conversion from type 'DBNull' to type 'Date' is not valid.
    >
    > What am I missing here? Is there an easy fix?
    >
    > Thanks,
    >
    > Craig Buchanan
    >
    >
    >
    =?Utf-8?B?QnJhdWxpbyBEaWV6?=, Aug 17, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Lozzi

    Dates dates dates dates... SQL and ASP.NET

    David Lozzi, Sep 29, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    859
    Rob Schieber
    Sep 30, 2005
  2. King Adrock
    Replies:
    0
    Views:
    387
    King Adrock
    Nov 8, 2005
  3. Replies:
    5
    Views:
    26,599
    Mike Schilling
    Mar 29, 2006
  4. Greg Smith

    Calendar control - disabling past dates.

    Greg Smith, Aug 14, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    9,155
    Mark Rae
    Aug 14, 2006
  5. PW

    Dates! Dates! Dates!

    PW, Aug 7, 2004, in forum: ASP General
    Replies:
    4
    Views:
    189
    Mark Schupp
    Aug 9, 2004
Loading...

Share This Page