Skip to content

Infragistics Community Forum / Desktop / Ultimate UI for ASP.NET Web Forms / Object of type Int32 cannot be converted to type Decimal

Object of type Int32 cannot be converted to type Decimal

New Discussion
Pedro
Pedro asked on Feb 21, 2014 5:16 AM

Dear Sirs.

It's good to write, since recently a new project we are working with WebDataGrid and insert data when using RowAdding, produces the following error:

 

Object of type 'System.Int32' cannot be converted to type 'System.Decimal'.

 

This happens when:

– The first time you insert data and columns: Calificacion1, Calificacion2, Promedio; have to System.Decimal DataType.

– The second inclusion if: Calificacion1, Calificacion2, Promedio; DataType have to System.String.

 

Is there any possible solution to this problem?

Thank you very much.

Sign In to post a reply

Replies

  • 0
    Victor Cavendish
    Victor Cavendish answered on Dec 15, 2011 9:08 PM

    I am experiencing the same problem.

    Using an ObjectDataSource, the EntityViewModel type used by my ObjectDataSource is Decimal. The SQL backend data is Decimal 38,4 

    It works properly if i use "10.1" but fails if i try to insert "10" or "10.0".

    Did you find a solution for this issue?

    Anyone out there with solutions? I have a case open with Infragistics but have no solution, yet.

    Thanks,

    Victor

    • 0
      Raymond
      Raymond answered on Jul 11, 2012 2:49 AM

      Hi I have the same problem here.
      I have apply an workaround which is i change the values in the WebDataGrid.EditingCore.RowAdding

      Let say my field with type Decimal is "Quantity", I add this code block to the RowAdding

      object x = e.Values["Quantity"];
              if (x is Int32)
              {
                  e.Values["Quantity"] = Convert.ToDecimal(x);
              }

      • 0
        Marcus Turnbull
        Marcus Turnbull answered on Feb 21, 2014 5:16 AM

        Thanks rayc1234!

        We were having the same issue though our error was to do with converting Decimal to Double – even though we had the field's datatype set to System.Double.  Only happened when adding a row where a non-integer number was entered.

        Even though the column was defined as…

        <ig:BoundDataField DataFieldName="UserAmount" Key="UserAmount" Width="70px" DataFormatString="{0:C0}" DataType="System.Double">

        …we still needed to add this to the RowAdding event.

                    object x = e.Values["UserAmount"];
                    if (x is System.Decimal)
                    {
                        e.Values["UserAmount"] = Convert.ToDouble(x);
                    }

        Probably a bug so I will submit to IG when I have a chance to build a sample project.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Pedro
Favorites
0
Replies
3
Created On
Feb 21, 2014
Last Post
12 years ago

Suggested Discussions

Created by

Created on

Feb 21, 2014 5:16 AM

Last activity on

Feb 16, 2026 9:31 PM