Rad Datepicker and DateTime Problem

3 posts, 0 answers
  1. Jorge
    Jorge avatar
    3 posts
    Member since:
    Nov 2012

    Posted 22 Nov 2012 Link to this post

    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. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 22 Nov 2012 Link to this post

    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.
  3. Jorge
    Jorge avatar
    3 posts
    Member since:
    Nov 2012

    Posted 23 Nov 2012 Link to this post

    Thanks Princy that solved my problem.
Back to Top