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

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.