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

Problem with double datatype in Grid, Clientside popup edit form

6 Answers 51 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ahmet Salih
Top achievements
Rank 1
Ahmet Salih asked on 26 Mar 2012, 07:42 PM
Hello all.


I have a nasty problem with an exception being thrown when the Grid control's pop-up editor updates my data.

First of all, let me give you the picture.

Using q1 2012 Telerik ASP.Net MVC3 extensions.

Model has this property:
public double MyDouble{get;set;}

Using Grid with Ajax editing, with GridEditMode.PopUp

Culture is us-EN

Each time I edit a row, the popup appears.. I used the data annotations for the double property to render Editor Templates/Numeric. the one that comes by default with Telerik installation.

The problem is this: when I enter any value containing a decimal, the database updates fine, but then an exception is thrown before the grid is updated via ajax. An example for a problem value is 33.5. An integer does not cause any error.

The picture of the screenshot is attached. I believe the inner exception is of particular import, kindly take note of it in the screenshot:

{"32.5 is not a valid value for Int32."}

Obviously a casting problem, but I cant understand why it happens.

Thanks in advance.

Edit: I forgot to mention that the exception is thrown from GridControllerExtensions.cs public static T ValueOf<T>(this ControllerBase controller, string key) method, around line 73.





6 Answers, 1 is accepted

Sort by
0
Dadv
Top achievements
Rank 1
answered on 28 Mar 2012, 04:34 PM
Hi,

I had a similar problem few days ago, the double was cast as in32 because of the ' . ', all was good if i use a ' , ' (French keyboard).

To fix the problem i just change double to decimal and all was good.


[DataType("Decimal")]
public decimal MyOldDoubleNowDecimal {get;set;}
 

Don't know if it's the same problem but this fix it for me.

Use Double or decimal for the good purpose.

Edit : you could try to use [DataType("Number")] in case double is required 
0
Ahmet Salih
Top achievements
Rank 1
answered on 29 Mar 2012, 12:59 PM
I've tried it with the suggestions above, but still no luck. I'm getting the same exception thrown by that casting operation.

When I try a value like "33,7" (with the decimal number being indicated by a comma instead of a dot) I get the obvious validation error: the field must be a number.

I should note again that the server culture is us-EN.

Isn't anyone else getting the same problem?
0
Dadv
Top achievements
Rank 1
answered on 29 Mar 2012, 01:06 PM
Could you provide a sample project?
0
Ahmet Salih
Top achievements
Rank 1
answered on 29 Mar 2012, 01:54 PM
So I go create a new solution, adding all the boilerplate to demonstrate that the problem exists, and....

...of course I can't recreate the problem. The grid works perfectly fine in the sample solution...

Investigating... will post if I discover anything worthwhile.
0
Ahmet Salih
Top achievements
Rank 1
answered on 29 Mar 2012, 02:20 PM
I found it!

I had a property named Size in my model.

This caused a naming clash with another property named Size in Telerik's Grid code.

Moral of the story: pay closer attention to naming clashes that might occur with external code.
0
Michael
Top achievements
Rank 1
answered on 15 Nov 2012, 12:57 PM
Hi,

experienced the same problems.The name of my property was "DisplayOrder". After renaming it  the problem was solved.

greetings,

michael

Tags
Grid
Asked by
Ahmet Salih
Top achievements
Rank 1
Answers by
Dadv
Top achievements
Rank 1
Ahmet Salih
Top achievements
Rank 1
Michael
Top achievements
Rank 1
Share this question
or