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

Comment Utility
>>> 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

Comment Utility

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
Comment Utility
<%# String.Format("{0:#0.00", DataBinder.Eval(Container.DataItem, "unitcost") / DataBinder.Eval(Container.DataItem, "retailprice") %>

Author Comment

Comment Utility
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

Comment Utility
Was writing from mind, sorry for mistakes.
Thanks for points and good luck

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

744 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

16 Experts available now in Live!

Get 1:1 Help Now