Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to display amount values with just a decimal point, comma seperators and a leading hyphen for negative values but with no dollar sign in a GridView in ASP.NET?

Posted on 2013-12-04
2
Medium Priority
?
1,030 Views
Last Modified: 2013-12-08
I am developing my first ASP.NET application in C# using VS2010.

I placed a (Data) GridView control on a Web Form.

For one of the fields titled AMT, this field that has an amount value and I just
want it to display the "Decimal point" and "Comma separator" as the DataFormatString.
How would I display the field in the GridView with just a decimal point and (thousands) comma separator. I don't want the dollar sign. And for negative amounts,  I want to precedie the amount with a dash.

For ex:

-80,000.00
        33.12
0
Comment
Question by:zimmer9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 27

Accepted Solution

by:
Chinmay Patel earned 2000 total points
ID: 39696202
 int result = -80000;
 string value = result.ToString("N2");

Open in new window


Source: http://stackoverflow.com/questions/1048643/format-a-double-value-like-currency-but-without-the-currency-sign-c
0
 

Author Comment

by:zimmer9
ID: 39696430
After dragging the GridView control from the Data section of the Tool Box onto my web form, I am trying to put a value into the "DataFormatString" field ofthe Smart Tag of the GridView control to convert a number into proper formatting.

The formatting I want is to put a dash in front of a negative number
and place a decimal point and (thousands) comma separator into a numeric value.

Thus, if the GridView row field is pulling from a database a value of 64786, the amount would be displayed in the GridView as 64,786.00

And if the GridView row field pulls in from a database a value of -221, it would appear in the GridView as -221.00.

The GridView field amount field is stored in default.aspx as follows:

If the GridView control cannot handle this editing "AMOUNT" field, then can the following ASPX CODE be modified to handle the reformatting of the AMOUNT field?

<asp:BoundField DataField="amount" HeaderText="Amount" SortExpression="amount" />
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question