Click here to Skip to main content
15,888,324 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[metro1.DAL.Tbl_Category]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[metro1.DAL.Tbl_Product]'.


What I have tried:

@model IEnumerable<metro1.DAL.Tbl_Category>
@{
    ViewBag.Title = "category";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>category</h2>

@foreach (var item in Model)
{
    <a href=" @Url.Action("SubCategory", "SubCategory", new { id = item.CategoryId })">Link</a>
    <!-- SECTION -->
    
   
                <!-- shop -->
                <div class="col-md-3 col-xs-12" >
                    <div class="shop">
                        <div class="shop-img">
                            <img src="~/metroStyl/img/shop01.png" />
                            <h5>@item.CategoryId</h5>
                        </div>
                        <div class="shop-body" >
                            <h3>@item.CategoryName<br>Collection</h3>
                            <a href="" class="cta-btn">@item.CategoryNameclass="fa fa-arrow-circle-right"></a>
                        </div>
                    </div>
                </div>
}
Posted
Updated 2-Apr-20 2:37am

1 solution

The view you've shown in your question is not the view you're trying to display when you get this error.

The view you're trying to display will start with:
Razor
@model IEnumerable<metro1.DAL.Tbl_Product>
You need to examine your action code to work out why you're trying to display the wrong view.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900