I have an integer stored in my database that I need to convert a string to.
This is my attempt at Eval:
<%# ChangeSalaryType(Eval("SalaryType")) %>
This is my attempt to function:
public static string ChangeSalaryType(int salaryType)
{
string salaryTime = string.Empty;
if (salaryType == 1)
{
salaryTime = "per hour";
}
else if (salaryType == 2)
{
salaryTime = "per week";
}
else if (salaryType == 3)
{
salaryTime = "per annum";
}
return salaryTime;
}
But I get the following errors:
Argument 1: cannot convert from 'object' to 'int'
Error 2 The best overloaded method match for 'controls_allPlacements.ChangeSalaryType(int)' has some invalid arguments
Error 4 The best overloaded method match for 'controls_allPlacements.ChangeSalaryType(int)' has some invalid arguments
I used "SalaryType" in Eval, since this is a parameter that contains information from the database. I'm not completely sure what I'm doing wrong.
source
share