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

DisplayFormat and ApplyFormatInEditMode

1 Answer 236 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
CHRISTIAN asked on 30 May 2011, 11:05 AM

I´ve bound a Property like this:

[DisplayFormat(DataFormatString = "{0:F0}", ApplyFormatInEditMode = true, ConvertEmptyStringToNull = false, NullDisplayText = "0")]
decimal value{ get; set; }

to a GridViewDataColumn like this:

<telerik:GridViewDataColumn DataMemberBinding="{Binding Value}" Header="Value"/>

but in Edit Mode it shows to decimal places.
Why is "ApplyFormatInEditMode" not working?

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 30 May 2011, 03:43 PM

Indeed, the string format is not applied in edit mode. If otherwise, the whole editing for that specific column might be broken. Unfortunately, there are quite many possible scenarios that may lead to damaging the functionality if such support is added. However, we will definitely consider introducing such a feature if being appropriate. 
A possible workaround would be to define a CellEditTemplate and set the StringFormat for the Binding:

<telerik:GridViewDataColumn DataMemberBinding="{Binding StadiumCapacity}"
                        <TextBox Text="{Binding StadiumCapacity, StringFormat=\{0:F0\}, Mode=TwoWay}" />

Still, whether this solution is appropriate depends entirely on your specific scenario and it is up to you to decide whether it fits into your requirements. 
Do let me know in case you need any further assistance.

All the best,
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
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question