473,385 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Using Null in DateTimePickers

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)
Nov 16 '05 #1
6 2321
John,

Unfortunately, the DateTimePicker doesn't support this. The best way to
do this is to have a checkbox to indicate whether or not it has a value.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"John Smith" <js@no.com> wrote in message
news:u$**************@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)

Nov 16 '05 #2
John Smith wrote:
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!


As Nicholas states, the DateTimePicker from MS does not support null.
There are third party controls that do. Infragistics
(www.infragistics.com) NetAdvantage Suite includes a calendar control
that supports null.
--
Tom Porterfield
Nov 16 '05 #3
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$**************@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)

Nov 16 '05 #4
Thanks everyone....But how incredibly depressing :)
"John Smith" <js@no.com> wrote in message
news:u$**************@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)

Nov 16 '05 #5
Thanks...the problem is though that if it's displaying today's date...the
user may think that is what is in the database and take action based upon
that.
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:ux**************@TK2MSFTNGP09.phx.gbl...
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$**************@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)


Nov 16 '05 #6
Hi,

What you can do is make clear than a date has not being selected, just
create a new control with a datetimepicker and a label, the label may
display some text for the user.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"John Smith" <js@no.com> wrote in message
news:uC**************@TK2MSFTNGP12.phx.gbl...
Thanks...the problem is though that if it's displaying today's date...the
user may think that is what is in the database and take action based upon
that.
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote in message news:ux**************@TK2MSFTNGP09.phx.gbl...
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$**************@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)



Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Partap Davis | last post by:
I asked this a couple days ago, but never got an answer, so I'll try to include some more detail: MySQL 4.0.12 on linux 2.4.18... I'm doing a join on 2 tables and trying to optimize it but I...
0
by: Michelle Keys | last post by:
I am trying to call a print function to print a string from a database using javascript. Which is RC_DATA of Varchar2(2500). This is a javascript is not being used. I have a thing that needs to...
3
by: John Smith | last post by:
Hello all: Does anyone happen to know the best way to handle null values for DateTimePickers? We have quite a few columns in our db that will not necissarily have a date for certain entries. ...
8
by: craigkenisston | last post by:
I have a generic function that receives a couple of datetime values to work with. They can or cannot have a value, therefore I wanted to use null. This function will call a database stored...
14
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the...
7
by: Harris | last post by:
Dear all, I have the following codes: ====== public enum Enum_Value { Value0 = 0, Value1 = 10,
1
by: WeCi2i | last post by:
Okay, I have a problem that has been stumping me for weeks. I have tried many different solutions and this is pretty much my last resort. I have seen a lot of good answers give here so I figured I...
1
by: borla123 | last post by:
Hi- I'm trying to make an application that computes the fee for parking a car in a parking garage. The user should provide the Time In: and Time Out: values by using DateTimePickers. The...
2
by: qwedster | last post by:
Folk! How to programattically check if null value exists in database table (using stored procedure)? I know it's possble in the Query Analyzer (see last SQL query batch statements)? But how...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.