Using a date time picker, I’m getting a can not contain null value error when clicking the Save button.
How can I fix that.
Thanks!
Printable View
Using a date time picker, I’m getting a can not contain null value error when clicking the Save button.
How can I fix that.
Thanks!
Can you show some code ?
There is no code I did not think that it needed code! cause the box already has text in it. "So I thought"
If I was to try it rite now without touching the DataTimePicker it would Error out, but if I was to just pull the picker down and click on 19 it would work fine ??? It just errors if the Date is not clicked.
Thanks!
I don't know what's this problem . I tried to generate any error but it's all working . Are you using any cutome formats ?
MM/DD/YY
That’s about it.
I have two Forms and it does the same thing on both
If it is seeing it as Null Value if not clicked, is there a way to code a date into it so that when using current date it don't have to be clicked?
Where'd you get this Date/Time Picker?
OK! I apologize if I did not make myself clear enough.
It is the DateTimePicker out of the Toolbox, it is a Data member in my DataSet
Something screwy is been happening. At first I was using just a text box witch kept on putting 12:00am behind my date, that is why I decided to go with the DateTimePicker.
All is well, unless I forget to Make a selection then I get the Null Value Error.
I was under the Impression that the DateTimePicker automatically displays today’s date and that it would be sufficient to make a Data entry.
I don’t Care witch one I use but they have both given me problems.
One adds 12:00am and the other don’t auto select the date.
???????
Your have to give it an initial value,weuse them and in the load event of the form always pust something like:
DateTimePicker1.Value = Now
unless of course you are binding it to exitisng data.
Your have to give it an initial value,weuse them and in the load event of the form always pust something like:
DateTimePicker1.Value = Now
unless of course you are binding it to exitisng data.
I don't know really what's wrong and had no problems with this control before . You don't even need to set any value . Just paste it on your form and it should , get today's date , no need for any code .
In my forays into date/time picking... I noticed the need for this:
1) If the user doesn't explicitly enter a value, the database should represent this as Null, not today's date.
2) The control in the VS toolbox sets itself to today's date/time by default when it loads, effectively demolishing the logic rule set in #1.
3) I always got around this by making a custom control that simply returns nothing in its DateTimeValue property if it was never set by the user, thereby effectively enforcing the first statement.
My DateTimePicker is bound to a database, and I have already found it to be a problem. It simply gets forgotten because the existing Date.
Is there any way to fix this?
Anyone?:confused:
what's the control for exactly? Couldn't you just use a date funtion and paste the info on a label? Or is this a control for databases or something?
I think your problem is that you are trying to bind a null value date to the control. Cannot think of anything else as have never experienced the sorts of problems you describe with this control.
Why not remove the binding and handle it through as Edit. Not a solution but I am at a loss as to understand why you are having the problems you do.
If necessary you can always add a handler and use that instead of binding directly and in the handler code determines what to do if to if you try to parse a null value date.
Perhaps post some code. I don't know and feel have nothing more I can contribute to this thread
Data binding is hell . If you want to cut off this problem , create a property or variable that set/get the value from DTP control using DTP.Value method . It's much more safer to the user of your program .
I was thinking that, but also hoping for an easy fix.
Thanks!
Do it this way to have more control on your code . I know it's a bit longer but the output is readable and maintainable code .