Looking for help on infragistic conversiont

3 posts, 0 answers
  1. Shelby
    Shelby avatar
    3 posts
    Member since:
    Sep 2013

    Posted 23 Jan 2014 Link to this post

    I am trying to convert to telerik RadDateTimePicker.

    Private
    Function CreateWebDateTimeEdit(ByVal controlName As String, ByVal dateOffset As Integer, ByVal dateMask As String, ByVal minimumdate As DateTime, ByVal maximumdate As DateTime, ByVal variabledefault As String) As WebDateTimeEdit
            Dim wdte As New WebDateTimeEdit
            wdte.ID = controlName
     
            wdte.Value = DateTime.Now.AddDays(dateOffset)
            wdte.DisplayModeFormat = dateMask
            wdte.EditModeFormat = dateMask
     
            If ViewState("VariableValues") IsNot Nothing AndAlso CType(ViewState("VariableValues"), Dictionary(Of String, String)).ContainsKey(controlName) Then
                wdte.Value = CType(ViewState("VariableValues"), Dictionary(Of String, String)).Item(controlName)
            ElseIf variabledefault.Length > 0 AndAlso Not variabledefault.ToUpper.Equals("[$NONE$]") Then
                wdte.Value = DateTime.Parse(variabledefault)
            End If
     
            wdte.MinValue = minimumdate
            wdte.MaxValue = maximumdate
     
            Return wdte
        End Function

    I tried the following.

    Private Function CreateWebDateTimeEdit(ByVal controlName As String, ByVal dateOffset As Integer, ByVal dateMask As String, ByVal minimumdate As DateTime, ByVal maximumdate As DateTime, ByVal variabledefault As String) As RadDateTimePicker
            Dim wdte As New RadDateTimePicker
            wdte.ID = controlName
     
            wdte.SelectedDate = DateTime.Now.AddDays(dateOffset)
            wdte.DataInput.DisplayModeFormat = dateMask
            'wdte.EditModeFormat = dateMask  //did not find a match
     
            If ViewState("VariableValues") IsNot Nothing AndAlso CType(ViewState("VariableValues"), Dictionary(Of String, String)).ContainsKey(controlName) Then
                'wdte.Value = CType(ViewState("VariableValues"), Dictionary(Of String, String)).Item(controlName)
                wdte.SeletedDate = CType(ViewState("VariableValues"), Dictionary(Of String, String)).Item(controlName)
            ElseIf variabledefault.Length > 0 AndAlso Not variabledefault.ToUpper.Equals("[$NONE$]") Then
                'wdte.Value = DateTime.Parse(variabledefault)
                wdte.SeletedDate = DateTime.Parse(variabledefault)
            End If
     
            wdte.MinDate = minimumdate
            wdte.MaxDate = maximumdate
     
            Return wdte
        End Function
    Everytime I try to save the dates to the database error
    The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.

    I am setting my date format to "M/dd/yyyy HH:mm"

    It is changing to M-dd-yyyy-hh-mm




  2. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 28 Jan 2014 Link to this post

    Hello Shelby,

    Use the DateFormat  (for edit) and DisplayDateFormat properties.

    //wdte.DisplayModeFormat = dateMask
    //wdte.EditModeFormat = dateMask
     
    wdte.DateInput.DateFormat = dateMask;
    wdte.DateInput.DisplayDateFormat = dateMask; // optional, use it only if it is different from the DateFormat


    Regards,
    Vasil
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Shelby
    Shelby avatar
    3 posts
    Member since:
    Sep 2013

    Posted 28 Jan 2014 in reply to Vasil Link to this post

    I tried both yet when I go to insert value to database my format never sets. It remain in this state M-dd-yyyy hh-mm

    I fixed the problem by converting the date format before it is pass the date parameter into this function. 
    Thanks anyway.
Back to Top