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

DataFormatstring {}{0:c2} doesn't work

4 Answers 304 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Angie
Top achievements
Rank 1
Angie asked on 03 Nov 2010, 06:17 PM


what i have as reference
 xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 





<
telerik:GridViewDataColumn  Header="Amount Paid" Width="150" IsReadOnly="True" IsGroupable="false" IsFilterable="True"
                                      DataMemberBinding="{Binding AmountPaid}" DataFormatString="{}{0:C2}"/>
                            <telerik:GridViewDataColumn>

What i get in the gridview is attached as a screen capture NOTE that AmountPaid is object of type of string
 does that matter???

4 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 03 Nov 2010, 06:32 PM
Hi Ravindranath,

 {0:C} applies only if the backing property's type is a numeric one - Integer, Double, Float, etc. You can either create another property on your data object that returns the string value converted as a double, or you can use a BindingConverter to perform the conversion in your binding.

Regards,
Yavor Georgiev
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
0
NGA TQ
Top achievements
Rank 1
answered on 10 Mar 2011, 04:12 AM
Hi!
I'm use DataFormatString for a column with type Money, but it doesn't work:

 

 

 

<telerikGridView:GridViewDataColumn TextAlignment="Right"

 

 

 

DataMemberBinding="{Binding UnitPrice,Mode=TwoWay}"

 

 

 

HeaderTextAlignment="Center"

 

 

 

Header="{Binding GlobalResource.INUnitPrice, Source={StaticResource MISAResource}}"

 

 

 

Width="110"

 

 

 

DataFormatString="{}{0:c1}"

 

 

 

>

 

 

 

 

 

<telerikGridView:GridViewDataColumn.CellEditTemplate>

 

 

 

 

 

 

 

 

 

 

 

 

<DataTemplate>

 

 

 

 

 

 

 

 

 

 

 

 

<MyLib:RadMaskedTextBox

 

 

 

 

 

 

 Value="{Binding UnitPrice,Mode=TwoWay}"/>

 

 

 

 

 

 

 

 

 

 

 

 

</DataTemplate>

 

 

 

 

 

 

 

 

 

 

 

 

</telerikGridView:GridViewDataColumn.CellEditTemplate>

 

 

 

 

 

 

 

 

 

 

 

 

</telerikGridView:GridViewDataColumn>

 

 

 

 

 

 

Database:
ColumnName    Data Type        Allows Null
UnitPrice             money             Unchecked

Thanks alot
0
Maya
Telerik team
answered on 10 Mar 2011, 10:54 AM
Hi,

May you provide a bit more details what is the behavior you expect and what is the one you get ? 
Based on the settings you are using, the currency mask will be applied only in view-mode, while in edit-mode you will see only the digits. If you want to display the currency in edit-mode too, you have to define the Mask property of the RadMaskedTextBox in the CellEditTemplate:

<telerik:GridViewDataColumn TextAlignment="Right"
                                            DataMemberBinding="{Binding UnitPrice,Mode=TwoWay}"
                                            HeaderTextAlignment="Center"                                               
                                            Width="110"
                                            DataFormatString="{}{0:c1}">
                    <telerik:GridViewDataColumn.CellEditTemplate>
                        <DataTemplate>
                            <telerik:RadMaskedTextBox
                                Value="{Binding UnitPrice,Mode=TwoWay}" MaskType="Numeric" Mask="c1"/>
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellEditTemplate>
                </telerik:GridViewDataColumn>

 

Greetings,
Maya
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Lavanya
Top achievements
Rank 1
answered on 18 Apr 2012, 06:41 AM
Hi,

I am using RAD GridView.I am pulling data from database and binding it to the gridview.For one column i need to divide by 60(to convert from seconds to minutes).The original source should be seconds as remaining manipulation will according to seconds.While displaying in the grid it should be in minutes.How can I do that??

Thanks in advance.
Tags
GridView
Asked by
Angie
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
NGA TQ
Top achievements
Rank 1
Maya
Telerik team
Lavanya
Top achievements
Rank 1
Share this question
or