Hi
How i can use below code in a view where List of Locations is also required & Individual Location also.
@Html.DisplayNameFor(model => model.Location.Id) | @Html.DisplayNameFor(model => model.Location.Description) | @Html.DisplayNameFor(model => model.Location.IsActive) | Action |
|---|---|---|---|
@Html.DisplayFor(model => item.Id) | @Html.DisplayFor(model => item.Description) | @if(item.IsActive) { } else { } | @if (item.IsActive) { } else { Delete } |
Thanks
Sachin SinghPosted Jul 1, 2021, 3:46 PM
Ramco RamcoPosted Jul 1, 2021, 3:34 PM
Hi Sachin
I am getting this error -
Server Error in '/' Application.
The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[MyApplication.Models.Location]', but this dictionary requires a model item of type 'MyApplication.Models.Location'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
********************** Controller
LocationDb dbLocation = new LocationDb();
dbLocation.GetAllLocation().ToList();
****************************** Index
@model MyApplication.Models.Location
Thanks
Sachin SinghPosted Jun 30, 2021, 7:02 PM