Search code examples
c#asp.net-coreblazorblazor-server-sidesyncfusion

cannot convert from method group to eventcallback blazor (Server App) - Sync Fusion Grid


I am using sync fusion grid in blazor server app. Inside grid I am using dropdown list. I wanna trigger the even on dropdown change event. When I try to bind the event using following code its giving me error "cannot convert from method group to eventcallback". Please help.

Below is the razor HTML code

<GridColumn HeaderText="Action" TextAlign="TextAlign.Center" Width="95">
    <Template>
        <SfDropDownList TItem="ActionDDLVM" Value="@((context as ActionDDLVM).Id)" TValue="string" PopupHeight="100px" Placeholder="Action" DataSource="@LstAction">
            <DropDownListEvents TValue="string" TItem="ActionDDLVM" OnValueSelect="OnSelect" ValueChange="ValueChange"></DropDownListEvents>
            <DropDownListFieldSettings Text="Text" Value="Id"></DropDownListFieldSettings>
        </SfDropDownList>
    </Template>
</GridColumn>

Below is the code in C# component partial class

public void OnSelect(SelectEventArgs args)
{

}

public void ValueChange(Syncfusion.Blazor.DropDowns.ChangeEventArgs<string> args)
{
    // you can get changed value in args.Value
}

Solution

  • Event arguments of OnValueSelect and ValueChange were defined wrongly. Please find the modified code example below.

    <GridColumn HeaderText="Action" TextAlign="TextAlign.Center" Width="95">
      <Template>
        <SfDropDownList TItem="ActionDDLVM" Value="@((context as ActionDDLVM).Id)" TValue="string" PopupHeight="100px" Placeholder="Action" DataSource="@LstAction">
          <DropDownListEvents TValue="string" TItem="ActionDDLVM" OnValueSelect="OnSelect" ValueChange="ValueChange" />
          <DropDownListFieldSettings Text="Text" Value="Id" />
        </SfDropDownList>
      </Template>
    </GridColumn>
        
    public void OnSelect(SelectEventArgs<ActionDDLVM> Args)
    {
    }
    public void ValueChange(ChangeEventArgs<string, ActionDDLVM> Args)
    {
    }