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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit If you want to manage em…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

738 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