Format Function

Posted on 2006-07-15
Last Modified: 2011-10-03
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") %>
Question by:dplsr
  • 3
  • 2
LVL 14

Expert Comment

ID: 17115227
>>> 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) & "%" %>

Author Comment

ID: 17115438

Hi Ramuncikas

this is still returning:  0.668217551740735

<%# DataBinder.Eval(Container.DataItem, "unitcost", "{0:N2}") / DataBinder.Eval(Container.DataItem, "retailprice" %>
LVL 14

Accepted Solution

Ramuncikas earned 500 total points
ID: 17115560
<%# String.Format("{0:#0.00", DataBinder.Eval(Container.DataItem, "unitcost") / DataBinder.Eval(Container.DataItem, "retailprice") %>

Author Comment

ID: 17115605
got it after a couple of fixes!

<%# String.Format("{0:#0.00}", DataBinder.Eval(Container.DataItem, "unitcost") / DataBinder.Eval(Container.DataItem, "retailprice")) %>
LVL 14

Expert Comment

ID: 17115623
Was writing from mind, sorry for mistakes.
Thanks for points and good luck

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Expando 4 46
Change data in datatable 8 30
Unable  to create new object 9 38 2010 11 18
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now