Eval("LessonNumer"),"{0:c}")  returns 1.00000000000 inside a listview

dmoss123
dmoss123 used Ask the Experts™
on
Anybody know why <%# Eval("LessonNumer"),"{0:c}") %>  is displaying the lesson number with decimal places.  Is there some extra property or something that needs to be set somewhere to get this working?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Software Engineer
Commented:

Try this

 <%# Eval("LessonNumer"),"${0}") %>

--Raj

Author

Commented:
That added a dollar sign but I still have a bunch of zeros.
Kevin CrossChief Technology Officer
Most Valuable Expert 2011

Commented:
Yes that formatting is for currency, so the decimals would be expected.
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Kevin CrossChief Technology Officer
Most Valuable Expert 2011
Commented:
This is a good reference for Format().

http://articles.techrepublic.com.com/5100-10878_11-5794526.html

Try :

<%# String.Format("{0:d}", Eval("LessonNumer")) %> 

Open in new window

Author

Commented:
I still get the decimals when I use a "d" for decimal

<%# Eval("LessonNumer"),"{0:d}") %>

Kevin CrossChief Technology Officer
Most Valuable Expert 2011

Commented:
Try casting to an Integer then :

<%# CInt(Eval("LessonNumer")) %>

Open in new window


<%# ((int)Eval("LessonNumer")).ToString() %>

Open in new window

just use {0:F0} as your string (fixed point number, 0 decimal places)
<%# String.Format("{0:F0}", Eval("LessonNumer")) %> 
 
--or--
 
<%# Eval("LessonNumer"),"{0:F0}") %>

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial