Basic Date Picker Forums

Welcome to Basic Date Picker Forums Sign in | Join | Help
in Search

SqlServerNull - 1/1/1900 - Don't want it to display in pop-up

Last post 12-01-2006, 2:41 AM by geoffrey.mcgill. 3 replies.
Sort Posts: Previous Next
  •  11-08-2006, 12:32 PM 884

    SqlServerNull - 1/1/1900 - Don't want it to display in pop-up

    Hi ...

    I have a BDPLite control located in a GridView control.  SQLServer does not allow nulls to be stored in the database for DateTime fields, so it stores 1/1/1900.  I have converted the column to a template and in the ItemTemplate, I run the control through a function to force the display to nothing for the BDPLite control.  This works fine.

    However, when the row is switched to Edit view, the BDPLite control shows the 1/1/1900 date.  How do I override and get it to display todays date?

    Thanks ...

    David

       Any day above ground is a good day!

  •  11-08-2006, 2:42 PM 887 in reply to 884

    Re: SqlServerNull - 1/1/1900 - Don't want it to display in pop-up

    Hi dlcollison,

    The solution is to bind to the new SelectedValue property. The SelectedValue property first became available in the version 1.2 release. You can download the latest build from http://www.basicdatepicker.com/download/

    The following sample details more information about binding to the SelectedValue property. See http://samples.basicdatepicker.com/autobinding.aspx

    If the TextBox is empty the Calendar will open to Today. If the TextBox contains a valid date, the Calendar will open to that date.

    You can set the date displayed in the TextBox, by setting the SelectedDate property (or SelectedValue).

    Hope this helps.

    Thanks,
    Geoffrey McGill
    ----------------------------------------
    Coolite Inc.
    Email: support [at] coolite [dot] com
    Phone: +1(888)775-5888
  •  11-08-2006, 4:25 PM 889 in reply to 887

    Re: SqlServerNull - 1/1/1900 - Don't want it to display in pop-up

    Thanks for jumping in to assist.

    I am binding to the SelectedValue property in the Template field of the GridViewControl as follows:

    <asp:GridView ID="grdMOCSigs" runat="server" SkinID="MOC" EmptyDataText="There are no active MOC Signature records to display ..." AutoGenerateColumns="False" AllowSorting="False" DataKeyNames="id" DataSourceID="objDSMOCSigs">

    <Columns>

    ....

    <EditItemTemplate>

    <BDP:BDPLite ID="datSignedBDP" runat="server" SelectedValue='<%# Bind("datSigned") %>' DateFormat="d" Width="125px" Enabled="True" />

    </EditItemTemplate>

    <ItemTemplate>

    <BDP:BDPLite ID="datSignedBDP" runat="server" SelectedValue='<%# FormatNullDate(Eval("datSigned")) %>' DateFormat="d" Width="125px" Enabled="False" />

    </ItemTemplate>

    ...

    </asp:GridView>

    Note that in the ItemTemplate, I call a function FormatNullDate that identifies the SQLServer field value of '1/1/1900' and then places the value "" in to the BDPLite control.  However, when I select the edit button, the grid then uses the EditItemTemplate to display and edit which then shows the value '1/1/1900'.  Note on a control that you want bound using <%#BIND()%>, you can not have it call a function - or at least that is my understanding of ASP.  So, that being said, BDPLite through BIND receives the value '1/1/1900' and displays it and uses it to select the initial date in the pop-up.  What I'm looking for is a way for BDPLite to ignore SQL Servers Date Null value of '1/1/1900'.

    Thanks ...

       David

       Any day above ground is a good day!

  •  12-01-2006, 2:41 AM 942 in reply to 889

    Re: SqlServerNull - 1/1/1900 - Don't want it to display in pop-up

    Hi dlcollison,

    Can you confirm that the "datSigned" field contains a Null value.

    When binding to the SelectedValue property, if the value coming from SQLServer is Null/DBNull, the date picker will be set to null as well.

    Since you are binding to the SelectedValue property and the date being displayed is '1/1/1900', I suspect that "datSigned" field in the database is not null, but is actually set to '1/1/1900'.  If that's the case, try manually changing the field in the database to null or run a script to change all the '1/1/1900' values to null.

    With the full version date picker (BasicDatePicker) you can set a custom null date with the NullDate property. By default the 'null' date is DateTime.MinValue, although you could change to any custom value such as DateTime.MaxValue or '1/1/1900'. The NullDate property is not available in BDPLite.

    Hope this helps.

    Thanks,
    Geoffrey McGill
    ----------------------------------------
    Coolite Inc.
    Email: support [at] coolite [dot] com
    Phone: +1(888)775-5888
View as RSS news feed in XML
 
Powered by Community Server, by Telligent Systems