ToString format

  • Thread starter Thread starter Brent Jenny
  • Start date Start date
B

Brent Jenny

I have the following function that takes in a string, converts it to a
double and adds it to a running total. I wnat to format it on return
to mey datagrid template column as currency. iget the following build
error The best overloaded method match for
'string.ToString(System.IFormatProvider)' has some invalid arguments.
The error happens on my return statement. Any ideas?



public string po_count(string po)
{
double tmp_dbl = double.Parse(po);
myPoTotal += tmp_dbl;

return po.ToString("C");
}

The following is my template column code.

<asp:TemplateColumn HeaderText="JO Order Value">
<ItemStyle Font-Size="8pt"></ItemStyle>
<ItemTemplate>
<%# po_count(DataBinder.Eval(Container.DataItem,
"po_price").ToString()) %>
</ItemTemplate>
</asp:TemplateColumn>
 
Use the .ToString("C") with DOUBLE values, not STRING.
With string values, to tostring() method with a parameter
string that represent a format.
 
Back
Top