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

ARC

I am getting following error:

The model item passed into the dictionary is of type 'Cygnus.Global.ViewModels.StoreViewModel', but this dictionary requires a model item of type 'Cygnus.Global.ViewModels.ProductOrderViewModel'.

Following is my Model code:

public class StoreViewModel
{
       public int Id { get; set; }

       public List<StoreViewModel> Stores { get; set; }


}

Following is my Controller Code:

public ActionResult StoreProducts (StoreViewModel model)
{
      CygnusInternalResponseViewModel response = new CygnusInternalResponseViewModel();
      response = new Logic(CApplicationId, CurrentCompanyId).GetProductsByStoreId(model.Id);
      var parentmodel = new ProductOrderViewModel() { Products = response.Model, Orders = new OrderViewModel() };
      if (response.Success)
          return View(model);

      return View();
}

And following is my View Code:

NOTE: StoreViewModel exists in ProductOrderViewModel as a property

@model Cygnus.Global.ViewModels.ProductOrderViewModel
@foreach (var pd in Model.Products)
            {
            <p>
             span class="cmtText"> | @pd.Name | @pd.UnitPrice </span>

            </p>
             }
            @Html.LabelFor(m => m.Orders.SubTotal)
            @Html.TextBoxFor(m => m.Orders.SubTotal, new { @readonly = "readonly", @style = "width:100px; float:right;margin-top:-21px;" })
ARC

I corrected my mistake in controller

public ActionResult StoreProducts (StoreViewModel model)
{
      CygnusInternalResponseViewModel response = new CygnusInternalResponseViewModel();
      response = new Logic(CApplicationId, CurrentCompanyId).GetProductsByStoreId(model.Id);
      var parentmodel = new ProductOrderViewModel() { Products = response.Model, Orders = new OrderViewModel() };
      if (response.Success)
          return View(model);

      return View();
}

To

public ActionResult StoreProducts (StoreViewModel model)
{
      CygnusInternalResponseViewModel response = new CygnusInternalResponseViewModel();
      response = new Logic(CApplicationId, CurrentCompanyId).GetProductsByStoreId(model.Id);
      var parentmodel = new ProductOrderViewModel() { Products = response.Model, Orders = new OrderViewModel() };
      if (response.Success)
          return View(parentmodel );

      return View();
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

The model item passed into the dictionary is of type ..., but this dictionary requires ...

From Java

The model item passed into the dictionary is of type .. but this dictionary requires a model item of type

From Dev

The model item passed into the dictionary is of type view model but requires generic IEnum

From Dev

The model item passed into the dictionary is of type 'Umbraco.Web.Models.RenderModel', but this dictionary requires a model item of type 'TestModel'

From Dev

The model item passed into the dictionary is of type 'BlogHomePageModel', but this dictionary requires a model item of type 'BlogHomePageModel'

From Dev

The model item passed into the dictionary is of type 'Sitecore.Mvc.Presentation.RenderingModel', but this dictionary requires a model item of type 'X'

From Dev

model item passed into the dictionary is of type 'System.Collections.Generic.List, but this dictionary requires a model item of type

From Dev

The model item passed into the dictionary is of type 'a', but this dictionary requires a model item of type 'b'

From Dev

model item passed into the dictionary is of type 'System.Boolean', but this dictionary requires a model item of type 'MyProject.checkboxstate'

From Dev

How to handle The model item passed into dictionary is type of LoginViewModel, but this dictionary requires a model type of RegisterViewModel?

From Dev

The model item passed into the dictionary is of type error

From Dev

The model item passed into the dictionary is of type 'System.Data.Entity.Infrastructure.DbQuery', but this dictionary requires a model item of type B

From Dev

The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[X]', but this dictionary requires a model item of type 'X'

From Dev

The model item passed into the dictionary is of type 'System.Data.Entity.Infrastructure.DbQuery', but this dictionary requires a model item of type B

From Dev

The model item passed into the dictionary is of type 'System.Int32', but this dictionary requires a model item of type 'IMS.Models.Dealer'

From Dev

ASP.NET MVC 5 The model item passed into the dictionary is of type 'Name.Models.IndexViewModel', but this dictionary requires a model item of type

From Dev

MVC Razor The model item passed into the dictionary is of type List String, but this dictionary requires IEnumerable

From Dev

The model passed into dictionary is type 'TestApp.Models.Registration.RegistrationVm' but this dictionary requires a model item of type System.String

From Dev

"The model item passed into the dictionary is of type" while passing model to a partial view

From Dev

"The model item passed into the dictionary is of type" while passing model to a partial view

From Dev

This dictionary requires a model item of type 'Umbraco.Web.Models.PartialViewMacroModel'

From Dev

dictionary requires a model item of type 'Projectname.Sp name'

From Dev

this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable

From Dev

How to fix The model item passed into the dictionary is of type error?

From Dev

The model item passed into the dictionary is of type 'System.Net.Http.HttpResponseMessage',

From Dev

How to fix The model item passed into the dictionary is of type error?

From Dev

The model item passed into the dictionary is of type 'System.Linq.Enumerable

From Dev

The model item passed into the dictionary is of type 'System.Data.Entity.DbSet

From Dev

MVC: The model item passed into the dictionary is of type System.Int32

Related Related

  1. 1

    The model item passed into the dictionary is of type ..., but this dictionary requires ...

  2. 2

    The model item passed into the dictionary is of type .. but this dictionary requires a model item of type

  3. 3

    The model item passed into the dictionary is of type view model but requires generic IEnum

  4. 4

    The model item passed into the dictionary is of type 'Umbraco.Web.Models.RenderModel', but this dictionary requires a model item of type 'TestModel'

  5. 5

    The model item passed into the dictionary is of type 'BlogHomePageModel', but this dictionary requires a model item of type 'BlogHomePageModel'

  6. 6

    The model item passed into the dictionary is of type 'Sitecore.Mvc.Presentation.RenderingModel', but this dictionary requires a model item of type 'X'

  7. 7

    model item passed into the dictionary is of type 'System.Collections.Generic.List, but this dictionary requires a model item of type

  8. 8

    The model item passed into the dictionary is of type 'a', but this dictionary requires a model item of type 'b'

  9. 9

    model item passed into the dictionary is of type 'System.Boolean', but this dictionary requires a model item of type 'MyProject.checkboxstate'

  10. 10

    How to handle The model item passed into dictionary is type of LoginViewModel, but this dictionary requires a model type of RegisterViewModel?

  11. 11

    The model item passed into the dictionary is of type error

  12. 12

    The model item passed into the dictionary is of type 'System.Data.Entity.Infrastructure.DbQuery', but this dictionary requires a model item of type B

  13. 13

    The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[X]', but this dictionary requires a model item of type 'X'

  14. 14

    The model item passed into the dictionary is of type 'System.Data.Entity.Infrastructure.DbQuery', but this dictionary requires a model item of type B

  15. 15

    The model item passed into the dictionary is of type 'System.Int32', but this dictionary requires a model item of type 'IMS.Models.Dealer'

  16. 16

    ASP.NET MVC 5 The model item passed into the dictionary is of type 'Name.Models.IndexViewModel', but this dictionary requires a model item of type

  17. 17

    MVC Razor The model item passed into the dictionary is of type List String, but this dictionary requires IEnumerable

  18. 18

    The model passed into dictionary is type 'TestApp.Models.Registration.RegistrationVm' but this dictionary requires a model item of type System.String

  19. 19

    "The model item passed into the dictionary is of type" while passing model to a partial view

  20. 20

    "The model item passed into the dictionary is of type" while passing model to a partial view

  21. 21

    This dictionary requires a model item of type 'Umbraco.Web.Models.PartialViewMacroModel'

  22. 22

    dictionary requires a model item of type 'Projectname.Sp name'

  23. 23

    this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable

  24. 24

    How to fix The model item passed into the dictionary is of type error?

  25. 25

    The model item passed into the dictionary is of type 'System.Net.Http.HttpResponseMessage',

  26. 26

    How to fix The model item passed into the dictionary is of type error?

  27. 27

    The model item passed into the dictionary is of type 'System.Linq.Enumerable

  28. 28

    The model item passed into the dictionary is of type 'System.Data.Entity.DbSet

  29. 29

    MVC: The model item passed into the dictionary is of type System.Int32

HotTag

Archive