Link to home
Start Free TrialLog in
Avatar of dplsr
dplsrFlag for Afghanistan

asked on

Format Function

I need examples of how to format the following:

it returns 0.668217551740735 now if have been

how do i round it off to .66

how about 66% (i have been fooling with the PERCENT Format name with no luck

<%# DataBinder.Eval(Container.DataItem, "unitcost", "{0:f}") / DataBinder.Eval(Container.DataItem, "retailprice") %>
Avatar of Ramuncikas
Ramuncikas
Flag of Lithuania image

>>> how do i round it off to .66
<%# DataBinder.Eval(Container.DataItem, "MyField", "{0:N2}") %>

>>> how about 66%
<%# CInt(DataBinder.Eval(Container.DataItem, "MyField") * 100) & "%" %>
Avatar of dplsr

ASKER


Hi Ramuncikas

this is still returning:  0.668217551740735

<%# DataBinder.Eval(Container.DataItem, "unitcost", "{0:N2}") / DataBinder.Eval(Container.DataItem, "retailprice" %>
ASKER CERTIFIED SOLUTION
Avatar of Ramuncikas
Ramuncikas
Flag of Lithuania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dplsr

ASKER

got it after a couple of fixes!

<%# String.Format("{0:#0.00}", DataBinder.Eval(Container.DataItem, "unitcost") / DataBinder.Eval(Container.DataItem, "retailprice")) %>
thanks!
Was writing from mind, sorry for mistakes.
Thanks for points and good luck