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

Can't seem to set FormatString for currency

3 Answers 139 Views
GridView
This is a migrated thread and some comments may be shown as answers.
hkdave95
Top achievements
Rank 2
hkdave95 asked on 27 Jul 2008, 08:30 AM
Hi

I am trying to set the FormatString for a column in GridView.

I have tried "{0:C}" and "{C}", but it does not seem to retain the value.

I have even tried entering the format string into the designer but with no success.

Is this a know problem ? Or am I doing something wrong ?

Kind Regards

3 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 28 Jul 2008, 01:37 PM
Hi hkdave95,

Thank you for the interest in RadGridView.

You will need to set the FormatString after binding the grid to data:

((GridViewDataColumn)
this.radGridView1.Columns["Price"]).FormatString = "{0:C}";

Hope this helps. Don't hesitate to contact us if you have other questions.

Kind regards,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
hkdave95
Top achievements
Rank 2
answered on 28 Jul 2008, 07:22 PM
Hi

Thanks for the reply.

This works great for the first column that I set it for but it does not work if I have two or three columns that need formatting.

Could you please confirm that I am doing it correctly ...

Me.rgvTransactions.Columns("T_nPrice").FormatString = "{0:C}" 
Me.rgvTransactions.Columns("T_nVATRate").FormatString = "{0:P}" 
Me.rgvTransactions.Columns("T_nTotal").FormatString = "{0:C}" 

T_nPrice - works ok
T_nVATRate - no formatting
T_nTotal - no formatting

Kind Regards

David
0
Peter
Telerik team
answered on 29 Jul 2008, 11:01 AM
Hello hkdave95,

Thank you for getting back to me.

I could not manage to repro the issue.
Could you take look in Designer.vb and tell me what is the type of T_nPrice,T_nVATRate and T_nTotal columns?

The Type should be  GridViewDecimalColumn, and in the initialization section T_nVATRate and T_nTotal should have properties .DataType = GetType(Decimal)

I hope this helps, if you have other questions, do not hesitate to contact me again.

Sincerely yours,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
hkdave95
Top achievements
Rank 2
Answers by
Peter
Telerik team
hkdave95
Top achievements
Rank 2
Share this question
or