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
Index
@Html.DisplayNameFor(model => model.Id)
@Html.DisplayNameFor(model => model.Description)
Action
@foreach (var item in Model)
{
@Html.DisplayFor(modelItem => item.Id)
@Html.DisplayFor(modelItem => item.Description)
Edit
}
@using (Ajax.BeginForm("CreateEdit", "Product", new AjaxOptions() { HttpMethod = "POST", UpdateTargetId = "frmProduct" }))
{
}
Thanks
Sachin SinghPosted Jun 15, 2021, 11:57 AM
Ramco RamcoPosted Jun 15, 2021, 11:38 AM
@model MyApplication.Models.Location
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>CreateEdittitle>
head>
<body>
@using (Html.BeginForm("CreateEdit", "Location", FormMethod.Post, new { @id = "locationFormId", @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
<div class="" 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>button>
<h4 Create New Location>h4>
div>
<div class="modal-body">
@*
Thanks
Location
*@
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.HiddenFor(model => model.Id)
<div class="form-group">
@Html.LabelFor(model => model.Id, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Id, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Id, "", new { @class = "text-danger" })
div>
div>
<div class="form-group">
@Html.LabelFor(model => model.Description, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Description, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Description, "", new { @class = "text-danger" })
div>
div>
div>
div>
div>
div>
}
body>
html>
Sachin SinghPosted Jun 15, 2021, 9:28 AM
class
="modal-title">Add New ProductRamco RamcoPosted Jun 15, 2021, 9:04 AM
Location
*@
Sachin SinghPosted Jun 15, 2021, 8:55 AM