C# - Using BoundField.DataFormatString To Format Currency Data?
Mar 29, 2011
I have a gridview that I am populating with data for the folks in accounting and they want me to format currency values so that they display without $'s, with commas separating digits and with negative numbers surrounded by ( )
e.g.:
12345.67 = 12,345.67
-12345.67 = (12,345.67)
I have found lots of examples around the interwebs that get me close but there is either no ( ) around negatives or there is a $ included.
I have gridview where there is column charges. If charges value is $0.00, I need to display it as BLANK or NULL that is it should be empty. I tried few DataFormatStrings but no luck.
In My SQl Database table column (named "Enterance_DateTime"), datetime is saved in below format:
2014-03-05 15:17:45 as yyyy-MM-dd HH:mm:ss in ASP.Net
But when I fetch this column in Gridview it shows datetime as below format:
4/5/2013 9:04:06 AM
I want to fetch exact datetime in Gridview what is saved in DB table.I tried using DataFormatString="{0:dd-MM-yyyy}" but is showing only date not time with it. How to achieve it.
in my below post there is a solution of currency format of a textbox and it is working fine.http://forums.asp.net/p/1544844/3779841.aspx#3779841but when i try it textbox within Gridview then it is working only "Empty Temlate" textbox.but not working within "Footer Template ".my code is like below
In database I have column date but when i enter date my font end view also display time for every date time remain same 12:00 AM ... I don't want to display date how can I do this?
With reference to the following thread: URL....I have problem applying the same concept to gridview EditItemTemplate. Is there a way i can add comma to large numbers and display it in currency format like exemple below:
Textbox3=Textbox1 * Textbox2
Textbox3= 1,000.00
Textbox3 should happen OnTextChanged and the above controls are in Gridview edit mode.
I have one one web page which one one textbox for receiving the dollar value. My requirement is the user should insert the digit following by a $ sysmbol. And the second requirement is the user has the permission to insert only like this $123.45. Before the decimal point it should not exceed three digits and after the decimal point it should not exceed two digits.
I have a label in a gridview which does a calc and works great however it does not format currency as expected. The label takes the bound value of QTY and multiples with the bound value of PRICE that is wrapped in a function to get a gross price.
I have searched and found various methods for formatting as a string decimal values but cant fine one which covers all my needs. I have to display a decimal value (a financial money figure) i.e. 2500.75
However I do not require any leading currency symbol such as $ or £ and the main point I am struggling with is that when the value has no value after the decimal do not display zeros. I thought
Code: .ToString(".##")
was meeting my requirements initiall but then realized if someone put the value 7.4 in it was displayed as 7.4 when it should be displayed as 7.40.
I am trying to take user supplied raw numeric values (these numbers dont have decimal point) and correctly format the values to their correct currency display.
eg: user enters 2341 the routine would use regex to format it to 23.41
I cant find a way to do this. What I have tried is this:
[Code]....
It doesnt work.... sNjunk always comes out 299 instead of 2.99.Anyone out there that can help me with this? or point me in the right direction?
I am using ASP.NET3.5. I have used MaskedEditExtender for currency purpose. when iam insering data into table it is accepting correct figures. while reading the same figures from database,I am displaying the figured in another textbox. (for second textbox i have used MaskedEditExtender) but it is displaying in that text box wrongly. suppose x=100 am reading this value from database and displaying x value in edit mode.but it is displaying 1.00. means it is taking last 2 digits as decimal points. how can I show in correct format?