Live Chat Icon For mobile
Live Chat Icon

Why do I get the error message ‘ CS1502: The best overloaded method match for ‘xxx(string)’ has some invalid arguments ‘ when I use Helper function in DataGrid

Platform: ASP.NET| Category: DataGrid

The function xxx() is expecting a string, but DataBinder.Eval() returns an object. So you must cast the result of DataBinder.Eval() to a string (or, in this case, just use .ToString()).

i.e, in your template do:


<%#xxx(DataBinder.Eval(Container.DataItem, 'field_name').ToString()) %> 

VB.NET


<%#xxx(DataBinder.Eval (CStr(DataBinder.Eval(Container.DataItem, 'field_name')) )%>

C#


<%# xxx((string) DataBinder.Eval(Container.DataItem, 'field_name'))%> 

Either of these should work.

Share with

Share on twitter
Share on facebook
Share on linkedin