Solved

format price in repeater

Posted on 2007-11-27
6
996 Views
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?
Anat


0
Comment
Question by:ANAT2403
[X]
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
6 Comments
 
LVL 12

Expert Comment

by:needo_jee
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}")%>)

0
 
LVL 12

Expert Comment

by:needo_jee
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);
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 20357919
Try it like this

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

Accepted Solution

by:
ANAT2403 earned 0 total points
ID: 20550546
Hi,
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();
Anat
0
 
LVL 1

Expert Comment

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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 and create new code templates in NetBeans IDE 8.0 for Windows.

688 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