This is a migrated thread and some comments may be shown as answers.

RadDateInput with a null value

8 Answers 312 Views
Input
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 07 May 2008, 08:13 PM
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

8 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 08 May 2008, 10:52 AM
 
0
Iana Tsolova
Telerik team
answered on 08 May 2008, 12:26 PM
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
0
Bob
Top achievements
Rank 1
answered on 08 May 2008, 05:28 PM
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
0
Iana Tsolova
Telerik team
answered on 10 May 2008, 10:23 AM
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
0
Rob Dismaya
Top achievements
Rank 1
answered on 22 Jul 2008, 06:39 PM
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.
0
Iana Tsolova
Telerik team
answered on 23 Jul 2008, 11:33 AM
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
0
Santiago
Top achievements
Rank 1
answered on 24 Jul 2008, 02:29 PM
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>


0
Iana Tsolova
Telerik team
answered on 25 Jul 2008, 10:51 AM
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.
Tags
Input
Asked by
Bob
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Iana Tsolova
Telerik team
Bob
Top achievements
Rank 1
Rob Dismaya
Top achievements
Rank 1
Santiago
Top achievements
Rank 1
Share this question
or