Solved

format price in repeater

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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 perform CRUD operations on a MySql database.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

708 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

15 Experts available now in Live!

Get 1:1 Help Now