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

dataform

1 Answer 172 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Radouane
Top achievements
Rank 1
Radouane asked on 16 Mar 2020, 01:00 PM
Hello , I hope you are well.

I have a problem and I need help , I'm working on a WPF project with Telerik UI , my issue is turning about CRUD System 

I Have those things : 
 - Entity Model Auto generated 
 - Dynamic RadDataForm with dynamic Data source for each Table in my Entity model.
 - SQL Server DataBase 

When I load my DataContext , the dataform dynamicly generated with Model types ( Ex : text feild for string types , date Picker for DateTime types ... ) unitil now all is good.

First problem : 

So for Float types when I add a new item and leaving the text field empty is working because it's not required in my data annotations but when I put a value and I change my mind after by let the value empty I got the error Validation message " input string format is incorrect " , knowing that my ( int , float ) values in my Model is Nullable ( I tried Nullable<flaot> and float? ) both cases the same error.

Note : I tried with the ( sdk-projects Telerik  and Demos - Telerik UI for WPF ) examples and same result. 

Second problem : 

In the RadDataForm for numeric values do I can't insert decimal numbers normally ? ( Ex: I wanna write 5.2  I found that I have to write 52 and use arrows position between ( 5 and 2 ) and then put the ' point (.) '

Thank you .

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 18 Mar 2020, 09:13 PM

Hello Radouane,

I already answered your question in your ticket. However, I am posting my answer also here. I hope it will help someone searching for similar issues.

The validation error that appears when the numeric value is empty comes from the WPF framework. You can reproduce the same behavior with a single TextBox data bind to a numeric value (like float or double). Basically, when the text gets changed, the framework is trying to parse the string to the corresponding data type, but an empty string is an invalid numeric value, so the error appears. 

In order to avoid the validation error, you will need to ensure that a valid number is entered. Alternatively, you can hide the validation error template, by setting the Validation.ErrorTemplate attached property on the TextBox editor to null. To do this, you can create a custom data field that derives from DataFormDataField and override its GetControl method. There, you can get the TextBox and set the property. You can see this approach in the attached project.

About the decimal point issue, I wasn't able to reproduce it. Can you check the attached project and let me know if I am missing anything?

Regards,
Martin Ivanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
General Discussions
Asked by
Radouane
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or