Compile error when invoking custom method on numeric input change event

I'm trying to implement something where when a numeric field changes, it automatically enters a value in another property. I've been having problems doing this as I learn more about Radzen so have stripped it back to a minimum to try and find the problem and cannot overcome this issue.

I have a simple entity and have created a test project. On either an Add or Edit page, I add a change event to a numeric input field.

It invokes a custom method which then triggers a notify with the summary set to ${result} which looks like this:

int GetPoints()
{
     return 15;
}

When I come to compile the application in wither Radzen or Visual Studio, I get this compilation error:

Argument 2: cannot convert from 'method group' to 'EventCallback' RadzenTest C:\Test\server\Pages\AddPokerResult.razor

If I look at the output generated in the razor file, I can see the offending line:

<RadzenNumeric style="display: block; width: 100%" @bind-Value="@((pokerresult.Position))" Name="Position" Change="@PositionChange">
</RadzenNumeric>

That Change="@PositionChange" event points to this method in the razor.designer.cs file:

protected async System.Threading.Tasks.Task PositionChange(decimal? args)
{
     var getPointsResult = GetPoints();
}

I can't make my mind up if I'm doing something wrong or if this is potentially a bug.

Any help would be appreciated.

Thanks.

Update

I found this issue on GitHub: https://github.com/dotnet/aspnetcore/issues/12226

If you read down to https://github.com/dotnet/aspnetcore/issues/12226#issuecomment-518860109 pranavkm suggests this solution:

  1. Use a delegate or perform an explicit cast
<InputSelect ValueChanged="(int x) => ChangedInt(x)" />

<InputSelect ValueChanged="(Action<int>)ChangedInt" />

So I manually changed:

<RadzenNumeric style="display: block; width: 100%" @bind-Value="@((pokerresult.Position))" Name="Position" Change="@PositionChange">
</RadzenNumeric>

to read:

<RadzenNumeric style="display: block; width: 100%" @bind-Value="@((pokerresult.Position))" Name="Position" Change="(int x) => PositionChange(x)">
</RadzenNumeric>

and the application now compiles and the expected notification popup occurs with the value of 15 in it as expected.

Hi @Paul_Pitchford,

Try adding an attribute called TValue with value int:

image

We will try to address the issue in Radzen so setting TValue isn't required.

That didn't work I'm afraid. I presume you meant adding the attribute to the numeric input box?

It produces this:

<RadzenNumeric style="display: block; width: 100%" @bind-Value="@((pokerresult.Position))" Name="Position" Change="@PositionChange" TValue="int">
</RadzenNumeric>

But it doesn't compile. We do however get a different error message:

No overload for 'AddPokerResultComponent.PositionChange(decimal?)' matches delegate 'Func<int, Task>'

What is the type of the Position property? I thought it was an int but it seems this is not the case.

You're correct, it's an integer.

Then the signature of the PositionChange event is wrong - it should have had int as an argument. Are you using the latest Radzen version?

I must have been a version behind because doing an update and using the fix you suggested has worked.

Thank you.