RadDateInput with a null value

9 posts, 0 answers
  1. Bob
    Bob avatar
    87 posts
    Member since:
    Jan 2008

    Posted 07 May 2008 Link to this post

    I have the following RadDateInput control on my web page.  I am loading this value as follows:

    <

    telerik:RadDateInput ID="diPremiumDueDate" runat="server" DateFormat="M/d/yyyy"

     DbSelectedDate='<%# Eval("PremiumDueDate") %>'>

    But I get an error when this value is null in my database.  How do I get around this?  I'd like the value to be blank on my web page when this happens.

    Thanks,
    Bob

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 08 May 2008 Link to this post

     
  3. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 08 May 2008 Link to this post

    Hello Bob,

    Have you tried using the Bind() mehod instead of the Eval():

    <telerik:RadDateInput ID="diPremiumDueDate" runat="server" DateFormat="M/d/yyyy"   
       DbSelectedDate='<%# Bind("PremiumDueDate") %>'

    Additionally, you could have a look at this online demo. I hope this helps.

    Regards,
    Iana
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  4. Bob
    Bob avatar
    87 posts
    Member since:
    Jan 2008

    Posted 08 May 2008 Link to this post

    Iana,

    I tried Bind instead of Eval but I get the same error.  Here is the error:

    Sys.WebForms.PageRequestManagerServerErrorException: Value of "1/1/001 12:00:00 AM" is not valid for selected date.  Selected Date should be between MinDate and MxDate.

    If I look at my date in my SQL table it is clearly Null.  But I notice it is 01/01/0001 in my radGrid.  I have an Edit button for each row in my radGrid and when clicked is when I get this error.  My Edit button calls a user control.  JNust for fun, I used MinDate = "01/01/0001" in my HTML.  It did not bomb out but instead displayed with 01/01/0001.  I just want it be blank in this case.

    Thanks,
    Bob
  5. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 10 May 2008 Link to this post

    Hi Bob,

    I followed your scenario and prepared a sample project for you. Please, find it attached to this post. Give it a try and let me know if I missed something from your code/logic. Please check if you are using the last version of RadControls for ASP.NET AJAX - Q1 2008 labeled 2008.1.415.

    Let us know if this helps.

    Sincerely yours,
    Iana
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Rob Dismaya
    Rob Dismaya avatar
    9 posts
    Member since:
    May 2007

    Posted 22 Jul 2008 Link to this post

    I'm having the same issue with 01/01/0001 is displaying in my datetimepicker. I would also like this to be blank because this is what is returning back as a null date. Thanks.
  7. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 23 Jul 2008 Link to this post

    Hi Rob,

    Could you please elaborate more on your scenario? Are you setting the DateTimePicker SelectedDate through binding expression? If the date assigned to the DateTimePicker is coming from database you should use the DbSelectedDate property to set the picker value. Thus if the returned value is null, the textbox will be empty.

    Review this demo for more information about RadDateTimePicker data-binding.

    Let us know how it goes.

    Sincerely yours,
    Iana
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  8. Santiago
    Santiago avatar
    37 posts
    Member since:
    Feb 2007

    Posted 24 Jul 2008 Link to this post

    I am having a similar problem



    The scenario is I'm updating an existing record inside the EditItem template of a formview control. The date in the DB is null, the user selects a data and hits the save THe problem is
    that I am getting back "" when I do a 
    FinalAcceptanceDate = (DateTime)e.NewValues["Final_Acceptance_Date"];

    inside the ItemUpdating event handler for the Formview..

    Here is my Markup: 
    <radCln:RadDatePicker ID="raddt_FinalAccpt" runat="server" CssClass="FieldInputsm"

    DbSelectedDate='<%# Bind("Final_Acceptance_Date") %>' SharedCalendarID="radCal" ToolTip='<%# Bind("Final_Acceptance_Date") %>'

    Width="90%" TabIndex="8">

    </radCln:RadDatePicker>


  9. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 25 Jul 2008 Link to this post

    Hello Santiago,

    Please find attached a sample project where RadCalendar works as expected in FormView edit template. Try it on your end and let me know if I missed something from your logic. 

    Greetings,
    Iana
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top