Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Format data string of gridview in currency Rs200.0

Author  Topic 

krishnet
Starting Member

29 Posts

Posted - 2007-05-13 : 13:48:52
Hello frdz,

I m using ASP.NET with C# 2.0

I want to use the dataformat string in the gridview to display the salary.
I have tried with the currency but it shows the amt in $ and i want it in Indian Rupees and to be displayed as

Rs1,00,000.00

<asp:BoundField DataField="salary" HeaderText="Salary" DataFormatString=" " htmlencode="False" />


Can anyone help to say what can be written ??
Any replies are appreciated...
thanxsRs1,00,000.00

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-05-13 : 13:53:19
Rs#,##,###.##

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

krishnet
Starting Member

29 Posts

Posted - 2007-05-16 : 06:02:29
Thanxs very much for ur suggestion..

But,it gives me the following error

Input string was not in a correct format.

Exception Details:System.FormatException: Input string was not in a correct format.

I have tried writting in diff ways as follows :

DataFormatString="{C:Rs#,##,###.##}"
DataFormatString=" Rs#,##,###.## "
DataFormatString="{Rs#,##,###.## }"

I need to format the string in the boundfield.

<asp:BoundField DataField="salary" HeaderText="Salary" DataFormatString=" Rs#,##,###.## " htmlencode="False" />

Without formating the field of salary it runs fine but i want to format it with the rupees.
Can u rectify where i m going wrong pls..

Ur help is needed again
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-05-16 : 06:47:38
What do you get if you use this?
<asp:BoundField DataField="salary" HeaderText="Salary" DataFormatString="#,##,###.## " htmlencode="False" />


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

krishnet
Starting Member

29 Posts

Posted - 2007-05-16 : 07:14:00
DataFormatString="{#,##,###.##}"...This gives the error
DataFormatString="#,##,###.##" ...This does not takes data from database but shows the same string in the gridview

thanxs
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-05-16 : 08:09:05
DataFormatString="Rs{0:#,###,###.##}"

http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.dataformatstring.aspx

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-05-16 : 10:53:26
Also note that it is not possible to format the currency in the way it is formatted in India

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

krishnet
Starting Member

29 Posts

Posted - 2007-05-16 : 13:04:38
Thanxs...jsmith8858
madhivanan try as jsmith8858 said it's working...

jsmith8858
The problem is that it does not allow the value after the decimal as "0"
if the value is 123.00 it accepts only 123 or
if it is Rs123.50 then only Rs123.5

That's fine but if u know how to take it as Rs123.50 then do let me know..
Thanxxs for ur help.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-05-16 : 13:58:51
DataFormatString="Rs{0:#,###,###.00}"

http://msdn2.microsoft.com/en-us/library/0c899ak8.aspx

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

krishnet
Starting Member

29 Posts

Posted - 2007-05-16 : 14:52:16
Thanxs very much...it worked out my frd successfully..
Got as i wanted the output..
This could be helpful to many members i think..
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-05-17 : 01:31:05
Well. As I told you earlier, the format you would get is, If the value is 100000,

100,000.00

If you want it to get in Indian way of formation, then you may try using

DataFormatString="Rs{0:#,##,###.00}"

so that you can get this format

1,00,000.00

But I doubt if the above formation is possible

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-05-17 : 08:15:03
Madhivanan -- no one told him earlier to use that exact format string; none of them included the "{0:" part. And you can get that format, try it! It's a custom format string -- you can have a format like "##,#,####,#,##" if you want ...

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-05-17 : 08:39:41
quote:
Originally posted by jsmith8858

Madhivanan -- no one told him earlier to use that exact format string; none of them included the "{0:" part. And you can get that format, try it! It's a custom format string -- you can have a format like "##,#,####,#,##" if you want ...

- Jeff
http://weblogs.sqlteam.com/JeffS



Thats cool. I am unable to test that as I dont use .NET


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -