Data Binding and formatting

C

Chris

Where can I find a fairly comprehensive list of the formatting codes used
when data binding. e.g. <%# Bind("Debit", "{0:C}") %>. Specifically
formatting a number to 2 decimal places. Regards, Chris.
 
R

Richard Carpenter

Winista said:
use "{0:C2}" for 2 decimal places..

On a related note, what does the "0" in {0:C2} indicate? I've seen
references to {1:xx} as well, though I've never seen it implemented.

Rich
 
C

chris

Rich,

the 0 in {0:C2} is the placeholder for the variable you are formatting.

You could say:
double myMoney = 1;
double yourMoney = 2;
string foo = string.Format("My money is {0:C3}, and your money is
{1:C3}.", myMoney, yourMoney);

foo would be "My money is $1.000, and your money is $2.000.

Chris
 
R

Richard Carpenter

chris said:
Rich,

the 0 in {0:C2} is the placeholder for the variable you are formatting.

You could say:
double myMoney = 1;
double yourMoney = 2;
string foo = string.Format("My money is {0:C3}, and your money is
{1:C3}.", myMoney, yourMoney);

foo would be "My money is $1.000, and your money is $2.000.

Thanks, chris. Out of curiosity, is that a known function from C or
something introduced with .Net? It looks familiar, but I don't recall
every encountering it in VB.

Rich
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top