[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


format price in repeater

Posted on 2007-11-27
Medium Priority
Last Modified: 2013-11-06
In ASP.NET 2.0 with C# I have a repeater that shows a price and I want to show it without any digit after the decimal point.
this is how I show it  inside the repeater:
<%# Eval("Price")%>
I thought of writing it like:
<%# Eval("Price","{0:N0}")%>
but it doesn't work.
How shall I write it?

Question by:ANAT2403
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
LVL 12

Expert Comment

by:Munawar Hussain
ID: 20357481
This would not remove trailing zeros
<%# Eval("Price","{0:N0}")%>

if currency is recqired then use
<%# Eval("Price","{0:c}")%>

You may use math.ceil or math.round to remove trialing zeros
or you can parse it to int using Javascript function?
int.Parse(<%# Eval("Price","{0:c}")%>)

LVL 12

Expert Comment

by:Munawar Hussain
ID: 20357531
sorry not int.parse
in js it should be pareint like this

parseint( <%# Eval("Price","{0:c}")%> )

'var a = parseInt(num);
'var b = parseFloat(num);
LVL 64

Expert Comment

by:Fernando Soto
ID: 20357919
Try it like this

    <%# Eval("Price","{0:F0}")%>

Accepted Solution

ANAT2403 earned 0 total points
ID: 20550546
Sorry but the only thing that worked for me in to write in the code behind the following:
            Label lblMin = (Label)e.Item.FindControl("lblMinPrice");
            string minpStr = String.Format("{0:C}", decimal.Parse(lblMin.Text));
            lblMin.Text = minpStr.ToString();

Expert Comment

ID: 20572463
Closed, 500 points refunded.
Community Support Moderator

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
Suggested Courses

649 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