This is a migrated thread and some comments may be shown as answers.

Formatting a currency value

3 Answers 222 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kathy
Top achievements
Rank 1
Kathy asked on 03 Oct 2010, 06:34 PM
I have a column that will show dollar amounts in the millions.  I want the data to display with comma separators.  The underlying data is stored as an integer ( although this is not cast in stone and can be made to be decimal if need be ).  If I use a GridMaskedColumn, I get the thousands separators, but it gives an error on the input type when I try to save it.  I'm using the autogenerated edit forms for this.  The mask is "###,###,###".  So I guess I need to get the data and convert it back to integer to save it.  Where do I go to cast this back to an integer?  Thanks.

3 Answers, 1 is accepted

Sort by
0
Andy Green
Top achievements
Rank 2
answered on 04 Oct 2010, 07:59 AM
You dont say where your data is coming from,

Assuming a SQL Server can you not use the SQL comman CONVERT and return the data already formatted?

If changing datatype you also might consider changing  to Money rather than Decimal as it has a higer internal accurancy, although not needed if you are sure to be only using integers.

Andy
0
Kathy
Top achievements
Rank 1
answered on 05 Oct 2010, 02:24 PM
I can use a masked column for the input and I'm assuming in the InsertCommand that I could take the value entered in the radgrid and remove the commas so that it can be stored in the db.  How would I go about locating that one particular field and removing the commas from it so that it's the correct datatype?
0
Marin
Telerik team
answered on 06 Oct 2010, 03:40 PM
Hi Kathy,

You may try setting the DataType property of the relevant column (i.e the GridMaskedColumn) to the correct type of the data. Or a better option is to use GridNumericColumn or GridBoundColumn and set the pattern for the number using the DataFormatString property. You may find additional information about different column types in this help topic and this live demo. If you still need to get the value from a certain items in the code-behind it can be done as shown in the following article.

Kind regards,
Marin
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Kathy
Top achievements
Rank 1
Answers by
Andy Green
Top achievements
Rank 2
Kathy
Top achievements
Rank 1
Marin
Telerik team
Share this question
or