Rob Venable
Top achievements
Rank 1
Rob Venable
asked on 24 Jan 2010, 04:20 PM
Hi,
I have a contact page that retrieves contact information from the database. When I populate all fields from the database, how do I set the date for my RadDatePicker textbox to that of birthdate value from my contact object.
ex: RadaDatePicker1.Value = Contact.Birthdate
Thanks
I have a contact page that retrieves contact information from the database. When I populate all fields from the database, how do I set the date for my RadDatePicker textbox to that of birthdate value from my contact object.
ex: RadaDatePicker1.Value = Contact.Birthdate
Thanks
5 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 25 Jan 2010, 06:42 AM
Hi Rob,
You can set the date for RadDatePicker as shown below.
CS:
RadDatePicker1.SelectedDate = (DateTime) Contact.Birthdate;
-Shinu.
You can set the date for RadDatePicker as shown below.
CS:
RadDatePicker1.SelectedDate = (DateTime) Contact.Birthdate;
-Shinu.
0
robertw102
Top achievements
Rank 1
answered on 27 Jan 2010, 02:20 PM
The proper way to set the selected date of a RadDatePicker control from the database would be like so:
RadDatePicker1.DbSelectedDate = Contact.BirthDate;
This way if the BirthDate is null, no error is thrown.
0
Rob Venable
Top achievements
Rank 1
answered on 28 Jan 2010, 01:18 AM
Hi,
Thanks for the information. Both scenarios worked.
Thanks for the information. Both scenarios worked.
0
Eric Larsen
Top achievements
Rank 1
answered on 19 Aug 2013, 08:36 PM
Error 32 Cannot convert type 'string' to 'System.DateTime'
please help.
please help.
0
Shinu
Top achievements
Rank 2
answered on 20 Aug 2013, 09:49 AM
Hi Eric,
Please try the following C# code.
C#:
Thanks,
Shinu.
Please try the following C# code.
C#:
RadDatePicker1.SelectedDate = DateTime.ParseExact(datestring,
"M/d/yyyy"
, CultureInfo.InvariantCulture);
Thanks,
Shinu.