Hi
Error - The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[MyApplication.Models.Product]', but this dictionary requires a model item of type 'MyApplication.Models.Product'.
@model IEnumerable<MyApplication.Models.Product> <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" /> <title>Index</title> </head> <body> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal" onclick="clearTextBox();"> <i class="fa fa-plus"></i> Add New</button><br /><br /> <div class="row"> <div class="col-xs-12"> <div class="box"> <div class="box-body"> <table class="table" id="tblProduct"> <thead> <tr> <th> @Html.DisplayNameFor(model => model.Id) </th> <th> @Html.DisplayNameFor(model => model.Description) </th> <th>Action</th> </tr> </thead> @foreach (var item in Model) { <tr> <td> @Html.DisplayFor(modelItem => item.Id) </td> <td> @Html.DisplayFor(modelItem => item.Description) </td> <td> <a class='btn btn-primary btn-sm' id='btnEdit'><i class='fa fa-pencil'></i> Edit </a> <a id="btnDelete" class="btn btn-danger btn-sm" data-toggle="modal" </td> </tr> } </table> </div> </div> </div> </div> @using (Ajax.BeginForm("CreateEdit", "Product", new AjaxOptions() { HttpMethod = "POST", UpdateTargetId = "frmProduct" })) { <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> <h4 class="modal-title">Add New Product</h4> </div> <div class="modal-body" id="frmProduct"> @Html.Partial("_CreateEdit") </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> <button type="submit" class="btn btn-primary">Save Changes</button> </div> </div> </div> </div> } </body> </html>
Thanks