Formatting a ItemTemplate column?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to test the ability to format a value by just appending a value
and returning it from the DataBinder.Eval in an ItemTemplate but I'm getting
the error below. Here is the code.

<script runat=server language=C#>
string FormatCompany(string name)
{
return name + "s";
}
</script>

<ItemTemplate>
<%# FormatCompany(DataBinder.Eval(Container.DataItem, "CompanyName"))%>
</ItemTemplate>

The best overloaded method match for
'ASP.Company_aspx.FormatCompany(string)' has some invalid arguments
 
Dave,
DataBinder.Eval returns an Object rather than a string, so you'll need
to cast it first.

Marcie
 
hi,
it seems that the datatype u r inputting is not of string type.type cast it
to string and apply
 
Back
Top