VIEW:
@model Hoda.Models.REVIEW
@using Hoda.Models
@using System.Collections.Generic;
@{
ViewBag.Title = "Create";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Create</h2>
@foreach (var item in Model)
{
@Html.DisplayFor(modelItem => item.Email)
<br />
@Html.DisplayFor(modelItem => item.Hondareviews)
}
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset class="form-horizontal">
<legend>REVIEW</legend>
<div class="control-group">
@Html.LabelFor(model => model.Email, new { @class = "control-label" })
<div class="controls">
@Html.EditorFor(model => model.Email)
@Html.ValidationMessageFor(model => model.Email, null, new { @class = "help-inline" })
</div>
</div>
<div class="control-group">
@Html.LabelFor(model => model.Hondareviews, new { @class = "control-label" })
<div class="controls">
@Html.EditorFor(model => model.Hondareviews)
@Html.ValidationMessageFor(model => model.Hondareviews, null, new { @class = "help-inline" })
</div>
</div>
<div class="form-actions no-color">
<input type="submit" value="Create" class="btn" />
</div>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
Controller:
public ActionResult Create(REVIEW r)
{
ProductDataDataContext db = new ProductDataDataContext();
db.REVIEWs.InsertOnSubmit(r);
db.SubmitChanges();
return RedirectToAction("Create");
}
This is my code for insert data using Linq,
After inserting that data will be display same page,
I am getting error like this
http://s17.postimg.org/a17gv36e7/image.png