﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » Strataframe Datetime picker control and null dates</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 14:18:53 GMT</lastBuildDate><ttl>20</ttl><item><title>Strataframe Datetime picker control and null dates</title><link>http://forum.strataframe.net/FindPost15245.aspx</link><description>I have spent quite a bit of time reviewing the forums and need to know what you suggest with Strataframe on this issue.&lt;/P&gt;&lt;P&gt;The SQL Database has datetime columns that do allow null values. I do not want them to reflect 1/1/1800 or 1/1/1900. I want them to reflect NULL if they are null. &lt;/P&gt;&lt;P&gt;My question is what settings need to be made in the BO Mapping as well as the datetime picker control to make this work.&lt;/P&gt;&lt;P&gt;I am using c#.</description><pubDate>Tue, 01 Apr 2008 09:11:10 GMT</pubDate><dc:creator>Ross L. Rooker, Sr.</dc:creator></item><item><title>RE: Strataframe Datetime picker control and null dates</title><link>http://forum.strataframe.net/FindPost15275.aspx</link><description>Thanks... worked like a charm in case anyone else needs to know.</description><pubDate>Tue, 01 Apr 2008 09:11:10 GMT</pubDate><dc:creator>Ross L. Rooker, Sr.</dc:creator></item><item><title>RE: Strataframe Datetime picker control and null dates</title><link>http://forum.strataframe.net/FindPost15271.aspx</link><description>You need to set a custom format to make the error go away.&amp;nbsp; This is actually not an issue but&amp;nbsp;by design when wanting to have the overall NULL support since we extend the capabilities of the underlying DateTimePicker.&amp;nbsp; You can have the DateTimePicker show any date or date/time combination that you want, but you need to use a CustomFormat.&amp;nbsp; The reason for this is because we have added a lot of functionality to the DateTimePicker for the NULL support as well as caret support when in a NULL state, etc.&amp;nbsp; So if you are going to use NULLs, then you need to use a custom format.&lt;OL&gt;&lt;LI&gt;Set the Format property to Custom&lt;/LI&gt;&lt;LI&gt;Set the CustomFormat property to the desired date display format.&amp;nbsp; You can get more details on this in the .NET documentation, but if you want to use a 04/01/2008 format, then it would look like this MM/dd/yyyy&lt;/LI&gt;&lt;/OL&gt;</description><pubDate>Tue, 01 Apr 2008 08:58:13 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Strataframe Datetime picker control and null dates</title><link>http://forum.strataframe.net/FindPost15270.aspx</link><description>BEN, I did what you indicated and it does work except when I use the DEL key to delete the date I get the error:&lt;/P&gt;&lt;P&gt;NullReferenceException&lt;BR&gt;&amp;nbsp; Object reference not set to an instance of an object.&lt;/P&gt;&lt;P&gt;Source&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : MicroFour StrataFrame UI&lt;/P&gt;&lt;P&gt;Stack Trace: &lt;BR&gt;&amp;nbsp;&amp;nbsp; at MicroFour.StrataFrame.UI.Windows.Forms.DateTimePicker.CreateManualCaret()&lt;BR&gt;&amp;nbsp;&amp;nbsp; at MicroFour.StrataFrame.UI.Windows.Forms.DateTimePicker.OnGotFocus(EventArgs e)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Control.WmSetFocus(Message&amp;amp; m)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Control.WndProc(Message&amp;amp; m)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.DateTimePicker.WndProc(Message&amp;amp; m)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Control.ControlNative&amp;#119;indow.OnMessage(Message&amp;amp; m)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Control.ControlNative&amp;#119;indow.WndProc(Message&amp;amp; m)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Native&amp;#119;indow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)&lt;BR&gt;&lt;/P&gt;&lt;P&gt;It appears about 3 times and then does blank out the date. Do you know why?</description><pubDate>Tue, 01 Apr 2008 08:49:54 GMT</pubDate><dc:creator>Ross L. Rooker, Sr.</dc:creator></item><item><title>RE: Strataframe Datetime picker control and null dates</title><link>http://forum.strataframe.net/FindPost15260.aspx</link><description>Hey Ross &lt;/P&gt;&lt;P&gt;Set the column to nothing in the BO Mapper. Then drop a datetimepicker on the form, add a checkbox to it nd in the edit button click you can use something like the code below. Then you users will be able to null the field out if they want to. It looks pretty cool too.&lt;/P&gt;&lt;P&gt;I am using the Infragistics control but the SF control should work the same. &lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;&lt;P&gt;**********&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Private Sub txtDateOfBirth_EditorButtonClick1(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinEditors.EditorButtonEventArgs) Handles txtDateOfBirth.EditorButtonClick&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim stateButton As StateEditorButton = CType(e.Button, StateEditorButton)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If (stateButton.Checked) Then&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; e.Button.Editor.Value = Nothing&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Else&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; e.Button.Editor.Value = DateTime.Today&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub</description><pubDate>Mon, 31 Mar 2008 09:41:23 GMT</pubDate><dc:creator>Michael Reese</dc:creator></item><item><title>RE: Strataframe Datetime picker control and null dates</title><link>http://forum.strataframe.net/FindPost15254.aspx</link><description>You'll want to make sure the values in the database are NULL for starters.&amp;nbsp; Then, you can use the BOMapper to customize the field(s) that are dates.&amp;nbsp; When you customize the field, there is a selection of Null Value Options that you can choose from.&amp;nbsp; You'll want the one that says Return Alternat on Null / Set Null on Alternate (value type).&amp;nbsp; Then, put &lt;/P&gt;&lt;P&gt;new DateTime(1800, 1, 1)&lt;/P&gt;&lt;P&gt;in for the replacement value.&amp;nbsp; When you access that field on the business object, it will return 1-1-1800 when the value in the database is Null and when you set the property to 1-1-1800, it will set the database to Null.&amp;nbsp; Set the corresponding properties on the DateTimePicker, too, and it will display blank when the value is 1-1-1800.&lt;/P&gt;&lt;P&gt;There are lots of creative ways to handle Null dates in .NET because of the fact that a date is a value type, not a reference type.&amp;nbsp; You could use&amp;nbsp;the Nullable&amp;lt;DateTime&amp;gt; generic (DateTime?), or you could google it and find some solutions like CSLA's SmartDate class that handles it in a unique way.</description><pubDate>Mon, 31 Mar 2008 08:59:04 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item></channel></rss>