Click here to Skip to main content
16,020,669 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have a textbox in RDLC. Now I want to change it into a currency format, but it does not work.

The display value of my textbox looks like this: 12345, not like this: $ 12,345.

What I have tried:

I tried to change my textbox expression from this: 
C#
=First(Fields!total.Value, "DataSet1"

to this:
C#
=Format( First(Fields!total.Value, "DataSet1")  ,"0.00")


and same not work.
Posted
Comments
charles henington 24-Aug-24 22:46pm    
total.Value? if this is a number, total.Value.ToString("N0")
or?
Format( First(Fields!total.Value, "DataSet1") ,"N0")
ras bry 24-Aug-24 23:16pm    
Good day sir charles henington, I try your code sir but not working.
charles henington 25-Aug-24 14:02pm    
int num = 12345;
Console.WriteLine(num.ToString("N0"));

This should print 12,345

Console.WriteLine($"${num.ToString("N0")}");

This should print $12,345
ras bry 25-Aug-24 17:01pm    
Thank you charles henington, its work
Vanessa Ross 19-Sep-24 0:47am    
@101 games I got the same issue.

1 solution

This should work, (not tested):

In the Text Box Properties dialog, go to the Number tab. Under Category, select Currency. In the Locale dropdown, select English (United States) to ensure the currency symbol is set to USD ($). Choose the desired format from the Sample section to see how it will look.

The XML should look like this for 2 decimal places :
XML
<Textbox Name="textbox1">
  <Value>=Fields!Amount.Value</Value>
  <Style>
    <Format>$#,##0.00</Format>
  </Style>
</Textbox>
 
Share this answer
 
Comments
ras bry 25-Aug-24 17:01pm    
thank you M-Badger

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900