We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

ValueChanged causes compiler error "Cannot Convert from 'method group' to 'EventCallBack'

Hi,

I am attempting to use the DateRangePicker control in a ServerSide Blazor application. When I attempt to configure the ValueChanged event as per the SyncFusion Documentation on Dynamic Values, I receive an error that "Cannot convert from 'method group' to 'EventCallback'. I am using the 17.3.0.17 version of the SyncFusion Blazor components and tried on .NET Core 3.0 Preview 9 and even updated to the .NET Core 3.1 Preview 1 and the problem persists.

<EjsDateRangePicker Placeholder="Choose a Range" StartDate="@CheckIn" EndDate="@CheckOut" ValueChanged="@onDateChange"></EjsDateRangePicker>


 private void onDateChange(RangeEventArgs args)

    {

        CheckIn = args.StartDate;

        CheckOut = args.EndDate;

        StateHasChanged();


    }



3 Replies

NP Narayanasamy Panneer Selvam Syncfusion Team October 22, 2019 07:07 AM UTC

Hi Scott,

 
Greetings from Syncfusion support.

 
We have validated the shared code example. From that we noticed, you may be faced an error due to improper approach of event binding. We have provided tag support for event binding. Kindly follow the below mentioned code example to resolve your issue.

Code example:
 
<EjsDateRangePicker ID="date-range"> 
    <DateRangePickerEvents ValueChange="@valueChange"></DateRangePickerEvents> 
</EjsDateRangePicker> 
 
@code { 
public void valueChange(Syncfusion.EJ2.Blazor.Calendars.RangeEventArgs args) 
{ 
  this.Data.Add(new PlaylistItemModel() { Title = "Change Eventtriggered" }); 
  this.StateHasChanged(); 
 
} 
} 

Also, we suggest you to use ValueChange event instead of using ValueChanged. Let us know if you need further assistance on this. 

Regards,
Narayanasamy P.
 




JS J. Scott October 22, 2019 02:30 PM UTC

I will give this a try. Please note that this approach is different from the guidance provided by the documentation: https://ej2.syncfusion.com/blazor/documentation/daterangepicker/data-binding/

ValueChange is not an option on the EjsDateRangePicker component which is why I used ValueChanged as it was the only option that was similar to the documentation.

From the documentation:
@using Syncfusion.EJ2.Blazor.Calendars

<p>DateRangePicker StarteDate and EndDate is: <strong> @StartValue </strong> and <strong> @EndValue </strong></p>

<EjsDateRangePicker StartDate="@StartValue" EndDate="@EndValue" ValueChange="@onChange"></EjsDateRangePicker>

@code {

public DateTime StartValue { get; set; } = DateTime.Now;

public DateTime EndValue { get; set; } = DateTime.Now;

private void onChange(RangeEventArgs args)
{
    StartValue = args.StartDate;
    EndValue = args.EndDate;
    StateHasChanged();
}
}


NP Narayanasamy Panneer Selvam Syncfusion Team October 23, 2019 07:02 AM UTC

Hi Scott,


Sorry for the in convenience caused.

We have already considered the Ug documentation refresh internally. The changes will be refresh with our upcoming patch release, which is schedule to release on end of October, 2019. We appreciate your patience until then.


Regards,
Narayanasamy P. 


Loader.
Live Chat Icon For mobile
Up arrow icon