c# - Return a null value from date control

Hi,

Visual Studio 2005, C#.net

I wish to return a NULL value from a date control if no date is
selected. Anyone got any idea on how i would do this?


Cheers
nologo [ Fr, 11 Januar 2008 14:07 ] [ ID #1905138 ]

Re: c# - Return a null value from date control

If I unsderstand... well, if you are using binding to a nullable
datetime (i.e. "DateTime?"), then it should just work automatically;
otherwise, check for DateTime.MinValue and substitute for your NULL.
In the other direction there is also a NullValue on a binding, which
is the value to display when the source is null.

Marc
Marc Gravell [ Fr, 11 Januar 2008 14:22 ] [ ID #1905139 ]

Re: c# - Return a null value from date control

Thanks for reply Marc, the DateTimePicker control has a mindate value
that only allows for the date format to be entered...so for example,
trying to return the value as NULL gives an error.
The mindate has a value preassigned in the date format
nologo [ Fr, 11 Januar 2008 14:28 ] [ ID #1905140 ]

Re: c# - Return a null value from date control

In that case, perhaps use the ShowCheckBox to indicate that no date
should be used, and look at .Checked as well as .Value?

Marc
Marc Gravell [ Fr, 11 Januar 2008 14:42 ] [ ID #1905143 ]
Microsoft » microsoft.public.dotnet.general » c# - Return a null value from date control

Vorheriges Thema: Object cannot be created at this URL because an object named by this
Nächstes Thema: PHP related problem