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

2 posts, 1 answers
  1. Hasanain
    Hasanain avatar
    8 posts
    Member since:
    Jun 2012

    Posted 27 Jul 2012 Link to this post


    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?

  2. Answer
    Dimitrina avatar
    3769 posts

    Posted 27 Jul 2012 Link to this post


     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: 


    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top