Hi,
I need to set DateTimePicker.DateInput.Text in codebehind, but the following error occurs when I set as dateTimeBirthDate.DateInput.Text = "2007/11/12"; for example.
Text property cannot be set. String was not recognized as a valid DateTime.
How could I set this property appropriately?
Thanks,
Ricky.
I need to set DateTimePicker.DateInput.Text in codebehind, but the following error occurs when I set as dateTimeBirthDate.DateInput.Text = "2007/11/12"; for example.
Text property cannot be set. String was not recognized as a valid DateTime.
How could I set this property appropriately?
Thanks,
Ricky.
5 Answers, 1 is accepted
0
Hi Ricky,
When working with a RadDatePicker you should use its SelectedDate property to change the value in the DateInput. Since this property is of type System.DateTime you should parse the string that you want to pass to the picker like this:
I hope this helps.
Sincerely yours,
Pavel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
When working with a RadDatePicker you should use its SelectedDate property to change the value in the DateInput. Since this property is of type System.DateTime you should parse the string that you want to pass to the picker like this:
RadDateTimePicker1.SelectedDate = System.DateTime.Parse("2007/11/12"); |
I hope this helps.
Sincerely yours,
Pavel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Ricky
Top achievements
Rank 1
answered on 29 Aug 2008, 02:17 AM
Hi Pavel
I know the way you provide to me. But we are leveaging wwDataBinder http://msdn.microsoft.com/en-us/magazine/cc163505.aspx to help data-binding process, and wwDataBinder is best to bind the value to controls' Text property.
Hence, if DateTimePicker.DateInput.Text can be assigned DateTime-format string, it would save us a lot.
Thanks,
Ricky.
I know the way you provide to me. But we are leveaging wwDataBinder http://msdn.microsoft.com/en-us/magazine/cc163505.aspx to help data-binding process, and wwDataBinder is best to bind the value to controls' Text property.
Hence, if DateTimePicker.DateInput.Text can be assigned DateTime-format string, it would save us a lot.
Thanks,
Ricky.
0
Hello Ricky,
Binding a RadDatePicker, RadTimePicker, or RadDateTimePicker control to a data source is easy provided you use the DbSelectedDate property. It works almost like the SelectedDate one, but does not throw an exception when given a null value.
In addition you can review the following help article:
http://www.telerik.com/help/aspnet-ajax/calendar_pickerdatabinding.html
Sincerely yours,
Plamen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Binding a RadDatePicker, RadTimePicker, or RadDateTimePicker control to a data source is easy provided you use the DbSelectedDate property. It works almost like the SelectedDate one, but does not throw an exception when given a null value.
In addition you can review the following help article:
http://www.telerik.com/help/aspnet-ajax/calendar_pickerdatabinding.html
Sincerely yours,
Plamen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Prashanth
Top achievements
Rank 1
answered on 29 Jan 2013, 03:55 PM
Hi,
I have a set of dates in database randomly . I am using raddatepicker . My issue was how to provide the dates to raddatepicker from database and only those dates should be enable , Remaining all dates should be disabled and cannot be selected.What is way to disable all dates expect those are in my database.
Regards,
Prashanth.
I have a set of dates in database randomly . I am using raddatepicker . My issue was how to provide the dates to raddatepicker from database and only those dates should be enable , Remaining all dates should be disabled and cannot be selected.What is way to disable all dates expect those are in my database.
Regards,
Prashanth.
0
okouin
Top achievements
Rank 1
answered on 09 Oct 2019, 08:52 AM
This look very simple for me
DatapickerName.Value= DateTime.Parse(dateToSet)