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

GridViewMaskedTextBoxColumn throwing validation errors for numeric input with MaskType="Numeric"

1 Answer 74 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Hasanain
Top achievements
Rank 1
Hasanain asked on 27 Jul 2012, 01:10 PM
Hello,

I have the following column defined in my xaml code

<
telerik:GridViewMaskedTextBoxColumn Mask="P1" MaskType="Numeric" 
DataMemberBinding="{Binding CurrentAllocationWeight}" 
DisplayIndex="1" IsReadOnly="True" DataFormatString="{}{0:P1}"  
Header="% Of Total" ColumnGroupName="CurrentAllocation"/> 

The bound property is a null-able decimal value. I have no other validation in the code-behind. When I try to enter a value in the cell, I get a validation error: "DecimalConverter cannot convert from System.Double".

How should I fix this, so that the user can enter say, 5.5, and it would display that value as "5.5%" in the cell?

Hasanain

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 27 Jul 2012, 02:23 PM
Hello,

 If you want to bind the GridViewMaskedTextBoxColumn to Decimal or Int , you should use Converter for the Binding. In the ConvertBack method you should manually convert back from Double.

As to the DataFormatString you could define it like so: 

DataFormatString="{}{0:#%}"

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
TreeListView
Asked by
Hasanain
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or