<pre lang="C#"> public ActionResult Create() { return View(); } // // POST: /HomeController/Create [HttpPost] [ValidateAntiForgeryToken] public ActionResult Create(DetailsEntry detailsentry) { if (ModelState.IsValid) { db.DetailsEntries.Add(detailsentry); db.SaveChanges(); //return RedirectToAction("Index"); } return View(detailsentry); } [HttpGet] public ActionResult displaydocument() { ViewBag.doctype = new SelectList(db.DocTypeMasters,"Id","DocTypeName"); return PartialView(); // return PartialView(); } protected override void Dispose(bool disposing) { db.Dispose(); base.Dispose(disposing); } } }
@model C3CardKYC1.Models.DetailsEntry @{ ViewBag.Title = "Create"; } <h2>Create</h2> @using (Html.BeginForm()) { @Html.AntiForgeryToken() @Html.ValidationSummary(true) <fieldset> <legend>DetailsEntry</legend> <div class="editor-label"> @Html.LabelFor(model => model.ClientId) </div> <div class="editor-field"> @Html.EditorFor(model => model.ClientId) @Html.ValidationMessageFor(model => model.ClientId) </div> <div class="editor-label"> @Html.LabelFor(model => model.ClientName) </div> <div class="editor-field"> @Html.EditorFor(model => model.ClientName) @Html.ValidationMessageFor(model => model.ClientName) </div> <div class="editor-label"> @Html.LabelFor(model => model.EmployeeId) </div> <div class="editor-field"> @Html.EditorFor(model => model.EmployeeId) @Html.ValidationMessageFor(model => model.EmployeeId) </div> <div class="editor-label"> @Html.LabelFor(model => model.EmpCitizenId) </div> <div class="editor-field"> @Html.EditorFor(model => model.EmpCitizenId) @Html.ValidationMessageFor(model => model.EmpCitizenId) </div> <div class="editor-label"> @Html.LabelFor(model => model.EmpName) </div> <div class="editor-field"> @Html.EditorFor(model => model.EmpName) @Html.ValidationMessageFor(model => model.EmpName) </div> <div class="editor-label"> @Html.LabelFor(model => model.Nationality) </div> <div class="editor-field"> @Html.EditorFor(model => model.Nationality) @Html.ValidationMessageFor(model => model.Nationality) </div> <div class="editor-label"> @Html.LabelFor(model => model.DocumentType) </div> <div class="editor-field"> @Html.EditorFor(model => model.DocumentType) @Html.ValidationMessageFor(model => model.DocumentType) </div> <p> <input type="submit" value="Create" /> </p> </fieldset> } <div> @Html.ActionLink("Back to List", "Index") </div> @Html.Partial("displaydocument",Model)
@model C3CardKYC1.Models.DocTypeMaster Select Document Type: @Html.DropDownList("DocTypeName", "Select");
I want to generate one view create.cshtl. Inside that i want to render displaydocumentview. I am getting this error. information: There is no ViewData item of type 'IEnumerable' that has the key 'DocTypeName'.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)