Trying to implement ValueChange Event getting CS1503 and CS1662 errors.

Package Syncfusion.Blazor 18.1.0.53
Target Framework netcoreapp.3.1

CS1503 Argument 2: cannot convert from 'Microsoft.AspNetCore.Components.EventCallback<System.DateTime>' to 'Microsoft.AspNetCore.Components.EventCallback' SHIMSWebPortal E:\Blazor Server 01\SHIMSWebPortal\SHIMSWebPortal\obj\Debug\netcoreapp3.1\Razor\Pages\_Timecards\Add.razor.g.cs 370 Active

CS1503 Argument 2: cannot convert from 'Microsoft.AspNetCore.Components.EventCallback<System.DateTime>' to 'Microsoft.AspNetCore.Components.EventCallback' SHIMSWebPortal E:\Blazor Server 01\SHIMSWebPortal\SHIMSWebPortal\Pages\_Timecards\Add.razor 1 Active


I am trying to implement the ChangeValue handler and getting those 2 errors above. My code in my Razor Component is: by the way just learning web programming. Been programming for windows desktop apps.

            <tr>
                <td>
                    <SfDateTimePicker TValue="DateTime?" TimeFormat="HH:mm" Step="15" @bind-Value="@timecard.ShiftClockIn">
                        <DateTimePickerEvents TValue="DateTime?" ValueChange="ValueChangeHandler"></DateTimePickerEvents>
                    </SfDateTimePicker>
                </td>
            </tr>

and the ValueChangeHandler:

    public void ValueChangeHandler(ChangedEventArgs<DateTime?> args)
    {
        timecard.ShiftClockOut = new DateTime(timecard.ShiftClockIn.Year, timecard.ShiftClockIn.Month, timecard.ShiftClockIn.Day, 12, 0, 0);
        timecard.LunchClockOut = new DateTime(timecard.ShiftClockIn.Year, timecard.ShiftClockIn.Month, timecard.ShiftClockIn.Day, 12, 0, 0);
        timecard.LunchClockIn = new DateTime(timecard.ShiftClockIn.Year, timecard.ShiftClockIn.Month, timecard.ShiftClockIn.Day, 12, 0, 0);
    }

PREVIOUS WORKING CODE:

                    <SfDateTimePicker TimeFormat="HH:mm" Step="15" @bind-Value="@(timecard.ShiftClockOut)"></SfDateTimePicker>

4 Replies

CH Charles May 26, 2020 02:33 AM UTC

I got it to compile and run by removing the ? in TValue = "DateTime?" in both the html and @code sections. 


SN Sevvandhi Nagulan Syncfusion Team May 26, 2020 04:24 AM UTC

Hi Charles, 


Thanks for the update. 

Please let us know if you need any more assistance. 

Regards, 
Sevvandhi N 



ÁN Ángel replied to Charles June 17, 2021 01:57 AM UTC

I got it to compile and run by removing the ? in TValue = "DateTime?" in both the html and @code sections. 

Hello Charles,
I'm facing the exact same situation, but here is still throwing the same error, i removed also de ? question marks for TValue in html and code, but still not working.
A diference is that the SFDateTimePicker is inside a SFTab, i don't know if that is related.


SN Sevvandhi Nagulan Syncfusion Team June 17, 2021 11:31 AM UTC

Hello Ángel, 
 
 
Greetings from Syncfusion support. 
 
 
We checked your query. We request that you to make sure that TValue should be same in all the places such as TValue property, event tag helper and event handler. If any of the places this TValue is mismatched the reported issue occurs. Please refer the below code example for your reference. 
 
 
@using Syncfusion.Blazor.Calendars 
 
<SfDateTimePicker TValue="DateTime" TimeFormat="HH:mm" Step="15" @bind-Value="@ShiftClockIn"> 
    <DateTimePickerEvents TValue="DateTime" ValueChange="ValueChangeHandler"></DateTimePickerEvents> 
</SfDateTimePicker> 
 
@code { 
    public DateTime ShiftClockIn { get; set; } 
 
    public void ValueChangeHandler(ChangedEventArgs<DateTime> args) 
    { 
        
    } 
} 
 
 
Kindly get back to us for further assistance. 
 
 
Regards, 
Sevvandhi N 


Loader.
Up arrow icon