Solved

format price in repeater

Posted on 2007-11-27
6
990 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
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

860 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