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

The model item passed into the dictionary is of type 'System.Decimal', but this dictionary requires a model item of type 'System.String'

2 Answers 576 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Atlas
Top achievements
Rank 1
Atlas asked on 22 Mar 2013, 04:21 PM
We are creating a grid based on the following Demo
The model for the demo has the unit price set up as follows:
[Required]
        [DisplayName("Unit price")]
        [DataType(DataType.Currency)]
        [Range(0, int.MaxValue)]
        public decimal UnitPrice
        {
            get;
            set;
        }

We are attempting to do the same thing in our application, but when we do so, we receive the following error:

The model item passed into the dictionary is of type 'System.Decimal', but this dictionary requires a model item of type 'System.String'

Am I missing something?
I don't see the model for the demo converting the unit price into a string, but the demo doesn't throw an error.

2 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 26 Mar 2013, 10:25 AM
Hi Atlas,


From the provided information it seems that the editor template for the "UnitPrice" property currently accepts only string type which is invalid configuration - please check the example of decimal editor template:

Currency.cshtml under the EditorTemplates folder:
@model decimal?
 
@(Html.Kendo().CurrencyTextBoxFor(m => m)     
      .HtmlAttributes(new {style="width:100%"})
      .Min(0)
)

Kind regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Atlas
Top achievements
Rank 1
answered on 26 Mar 2013, 06:24 PM
That is correct. Thanks for the help. I figured it out myself after the post, but was unable to open this item to post my reply.
Clicking on the reply link in the email worked though.
Tags
Grid
Asked by
Atlas
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Atlas
Top achievements
Rank 1
Share this question
or