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

Rad Datepicker and DateTime Problem

2 Answers 146 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jorge
Top achievements
Rank 1
Jorge asked on 22 Nov 2012, 07:04 PM
Hello,

When I try to use raddatepicker.selecteddate  for a datetime var I get this error:

Cannot implicitly convert type 'object' to 'System.DateTime'. An explicit conversion exists (are you missing a cast?)
 
Here is my code:

    public partial class RegistroFalla
    {
        public int ID_Falla { get; set; }
        public Nullable<int> Duracion_Falla { get; set; }
        public System.DateTime Fecha { get; set; }
        public System.DateTime Hora_Deteccion { get; set; }
        public System.DateTime Hora_Diagnostico { get; set; }
        public System.DateTime Hora_Ocurrencia { get; set; }
        public System.DateTime Hora_Recuperacion { get; set; }
        public System.DateTime Hora_Solucion { get; set; }
        public string Descripcion { get; set; }
        public System.DateTime Tiempo_Deteccion { get; set; }
        public System.DateTime Tiempo_Recuperacion { get; set; }
        public System.DateTime Tiempo_Reparacion { get; set; }
        public System.DateTime Tiempo_Respuesta { get; set; }
        public string Division { get; set; }
    }

   var Fallo = new RegistroFallas.Model.RegistroFalla
                {
                    Hora_Ocurrencia = dpOcurrencia.SelectedDate,
                    Fecha = rdpFecha.SelectedDate,
                    Descripcion = txtDescripcion.Text,
                    Hora_Deteccion = rdpDeteccion.SelectedDate,
                    Hora_Diagnostico = rdpDiagnostico.SelectedDate,
                    Hora_Solucion = rdpSolucion.SelectedDate,
                    Hora_Recuperacion = rdpRecuperacion.SelectedDate
                };


Thanks,

Jorge

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Nov 2012, 03:35 AM
Hi Jorge,

The SelectedDate property specifies the currently selected date of the RadDatePicker. You can get the value to a DateTime variable using the value property of the SelectedDate as follows.

C#:
Hora_Deteccion = rdpDeteccion.SelectedDate.Value,
Hora_Diagnostico = rdpDiagnostico.SelectedDate.Value,
Hora_Solucion = rdpSolucion.SelectedDate.Value  ,
Hora_Recuperacion = rdpRecuperacion.SelectedDate.Value

Hope this helps.

Regards,
Princy.
0
Jorge
Top achievements
Rank 1
answered on 23 Nov 2012, 07:26 PM
Thanks Princy that solved my problem.
Tags
General Discussions
Asked by
Jorge
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jorge
Top achievements
Rank 1
Share this question
or