Basic Date Picker Forums

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

Setting Value in Textbox

Last post 05-23-2006, 4:32 PM by geoffrey.mcgill. 2 replies.
Sort Posts: Previous Next
  •  05-23-2006, 2:15 PM 526

    Setting Value in Textbox

    I am attempting to set the textbox value but get an error...Here is the code and error statement.  Any thoughts?

     

    DataBinder.Eval(Container.DataItem, "BEGIN_DATE")

     

    Specified cast is not valid.

     

    I am assuming I need to convert this to a DateTime, but that didn't seem to work either?

  •  05-23-2006, 3:45 PM 527 in reply to 526

    Re: Setting Value in Textbox

    Nevermind, I was able to get it working...

  •  05-23-2006, 4:32 PM 528 in reply to 526

    Re: Setting Value in Textbox

    Hi isteve,

    Yes this appears to be a casting issue. The SelectedDate property must be set with a DateTime object. The following sample demonstrates binding the date picker within a DataGrid. See http://basicdatepicker.com/samples/item3.aspx

    Another issue to be aware of is how Null values or empty dates are handled when trying to bind to SelectedDate. There is no Null within the DateTime object, so you 'fake' it with a replacment value. Within the date picker we use DateTime.MinValue as the replacement for Null or empty date. So, in the sample above, we check whether a value exists that can be converted into a DateTime object or return DateTime.MinValue to represent a Null date.

    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