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

Set dateTimeBirthDate.DateInput.Text in CodeBehind

5 Answers 557 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Ricky
Top achievements
Rank 1
Ricky asked on 28 Aug 2008, 02:37 AM
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.

5 Answers, 1 is accepted

Sort by
0
Pavel
Telerik team
answered on 28 Aug 2008, 07:11 AM
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:
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.
0
Missing User
answered on 29 Aug 2008, 07:14 AM
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.
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.
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)

Tags
Calendar
Asked by
Ricky
Top achievements
Rank 1
Answers by
Pavel
Telerik team
Ricky
Top achievements
Rank 1
Missing User
Prashanth
Top achievements
Rank 1
okouin
Top achievements
Rank 1
Share this question
or