DropDownList ValueChange Error: cannot convert from 'method group' to 'EventCallback'.

Hello I upgraded from an older version to the latest one and I am getting an error while trying to use the ValueChange.Here is my code:

<SfDropDownList ShowClearButton = "true" DataSource="@Dropdown" TValue="string" TItem="string">
     <DropDownListEvents TItem = "string" TValue="string" ValueChange="OnChange"></DropDownListEvents>
</SfDropDownList>

My data source:
List<string> Dropdown = new List<string>{
        "✓",
        "⨯"
};

private void OnChange(Syncfusion.Blazor.DropDowns.ChangeEventArgs<string> args){
...
}

The error im getting is:

error CS1503: Argument 2: cannot convert from 'method group' to 'EventCallback'.




5 Replies 1 reply marked as answer

SP Sureshkumar P Syncfusion Team October 9, 2020 08:46 AM UTC

Hi Tom, 
 
Greetings from Syncfusion support. 
 
Based on your shared information with code example, we suggest you use TItem with TValue in the change event argument type to resolve the issue. 
 
Please find the code example here: 
@using Syncfusion.Blazor.DropDowns 
@using System.Collections.Generic; 
 
<SfDropDownList ShowClearButton="true" DataSource="@Dropdown" TValue="string" TItem="string"> 
    <DropDownListEvents TItem="string" TValue="string" ValueChange="OnChange"></DropDownListEvents> 
</SfDropDownList> 
 
@code{ 
 
    List<string> Dropdown = new List<string>{ 
        "", 
        "" 
}; 
 
    private void OnChange(Syncfusion.Blazor.DropDowns.ChangeEventArgs<stringstring> args) 
    { 
 
    } 
}  
 
 
Regards, 
Sureshkumar P 


Marked as answer

TD Tom Dimos October 12, 2020 11:54 AM UTC

Thanks a lot!!!


SP Sureshkumar P Syncfusion Team October 13, 2020 11:09 AM UTC

Hi Tom, 
 
Thanks for your update. 
 
Regards, 
Sureshkumar P 



MA Mark August 6, 2021 07:37 AM UTC

I have have the same problem, but cannot see what I am doing wrong.  Please help:

<ToolbarItem Type="ItemType.Input">

                    <Template>

                        <div><strong>Records</strong></div> 

                        <SfDropDownList ID="recordsPicker" TItem="string" TValue="string" Width="150" @bind-Value="RecordsPicker" DataSource="@RecordsSource">

                            <DropDownListEvents TItem="string" TValue="string" ValueChange="OnChange" ></DropDownListEvents>

                        </SfDropDownList>

                    </Template>

With code in the base file of 

public async Task OnChange(ChangeEventArgs<string, string> args)

        {

            switch (args.Value)

            {

            

            }

        }




BC Berly Christopher Syncfusion Team August 6, 2021 04:31 PM UTC

Hi Mark, 
  
We have checked the DropDownList component with ValueChange event inside the Toolbar component. But the reported issue does not occurred at our end. We suspect that you may be facing namespace conflicts for the ChangeEventArgs class in your application. So, we suggest you to ensure to use as like the below highlighted code to overcome the problem you are facing,  
  
public async Task OnChange(Syncfusion.Blazor.DropDowns.ChangeEventArgs<string, string> args) 
 
    { 
} 
 
  
For your convenience, we have prepared the sample and attached it below, 
  
And if you are still facing difficulties, then kindly share with us the screenshot showing the reported problem in your VS application.  
  
Regards, 
Berly B.C 


Loader.
Up arrow icon