Re: Using Null in DateTimePickers

From: Ignacio Machin \( .NET/ C# MVP \) ("Ignacio)
Date: 08/27/04


Date: Fri, 27 Aug 2004 09:39:41 -0400

Hi Jon,

 I want to add an approach that I used once in a web app, as DateTime does
not support null you need to define a null value inside its range, I
selected a date that was not possible in my domain ( I think you could also
use DateTime.MinDate ), so what I do is assign it as the selectedDate, but I
set the visible Date to today, therefore the controls is happy cause it has
a value and as this value is way outside the domain it will never be
displayed.

 Maybe this does not solve your problem 100% but it may give you other
ideas.

Cheers,

-- 
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"John Smith" <js@no.com> wrote in message
news:u$PtFYDjEHA.1712@TK2MSFTNGP09.phx.gbl...
> Hey folks,
>
> I have a DateTimePicker control on my Windows Form.  Whenever I either:
> a) Don't give it a value
> b) Set it's value to Null
> c) Set it's value to ""
> It makes the date today's date.
>
> I need it to be empty though.  How do I make it empty?  It represents a
> field in my database which legitimately can be null and so I can't show it
> as todays date.
>
> Thanks a lot for the help!
>
>
>
> (I posted a similar message a couple of days ago without a response, but
> it's really important and time is of the essence so I'm trying again)
>
>


Relevant Pages

  • Re: DateTime Picker
    ... The DateTimePicker has no concept of empty dates. ... datetime really) or it's NULL. ... You have to catch the state of the control in the Change event and update ... > Also be sure to set the MinDate and MaxDate properties. ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Convertin dbnull to string
    ... I think what you should do is to assign dbnull value to ... >a valid DateTime. ... >> DbNull is a special value and not an empty string. ...
    (microsoft.public.dotnet.framework.adonet)
  • Custom Web Control
    ... SelectedDate, MaximumDate, MinimumDate are ... private DateTime minimumDate = DateTime.MinValue; ...
    (microsoft.public.dotnet.languages.csharp)
  • Custom Web Control
    ... SelectedDate, MaximumDate, MinimumDate are ... private DateTime minimumDate = DateTime.MinValue; ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • View State Null In IPostBackHandler
    ... I had a datetimepicker server control that worked great in 1.x but I am ... having trouble with it in ASP.NET 2.x For some reason, the ViewState value ... DateTime PreviousSelectedDate = SelectedDate; ...
    (microsoft.public.dotnet.framework.aspnet.buildingcontrols)

Loading