Round value in label

  • Thread starter Thread starter staeri
  • Start date Start date
S

staeri

I want to round the value in a label to one decimal. The value is set
with the following code:

Text='<%# Eval("ValueToRound") %>'

How can I do that?

Regards,

S
 
There are 2 ways to do this, either call round directly:

Text='<%# Math.Round(Eval("ValueToRound", 2)) %>'

(for the life of me I can't remember if the return from Eval needs to be
cast)

or use the 2nd parameter of Eval to format the value:

Eval("ValueToRound", {0:#0.00})

You can see more formatters at:
http://msdn2.microsoft.com/en-us/library/0c899ak8.aspx

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top