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

Looking for help on infragistic conversiont

2 Answers 45 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Shelby
Top achievements
Rank 1
Shelby asked on 23 Jan 2014, 07:03 PM
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 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 28 Jan 2014, 08:40 AM
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.
0
Shelby
Top achievements
Rank 1
answered on 28 Jan 2014, 02:02 PM
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.
Tags
Calendar
Asked by
Shelby
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Shelby
Top achievements
Rank 1
Share this question
or