I have a create view with two cascading dropdownlists one for dead individuals and living individuals. If I do use code for the two cascading dropdownlists, the create view works no problem. Now when I use it with the cascading dropdownlist it gives me a error, the error is as follows:
Server Error in '/' Application.
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_dbo.Individuals_dbo.Cities_CitieDeads_CitieId". The conflict occurred in database "C:\GENEALOGYTEST\MVCNOK\MVCNOK\APP_DATA\MVCNOKDB.MDF", table "dbo.Cities", column 'CitieId'.
The statement has been terminated.
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.
Exception Details: System.Data.SqlClient.SqlException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_dbo.Individuals_dbo.Cities_CitieDeads_CitieId". The conflict occurred in database "C:\GENEALOGYTEST\MVCNOK\MVCNOK\APP_DATA\MVCNOKDB.MDF", table "dbo.Cities", column 'CitieId'.
The statement has been terminated.
Source Error:
Line 82: {
Line 83: db.Individuals.Add(individual);
Line 84: db.SaveChanges();
Line 85: return RedirectToAction("Index");
Line 86: }
Source File: C:\GenealogyTest\MvcNOK\MvcNOK\Controllers\IndividualsController.cs Line: 84
Stack Trace:
[SqlException (0x80131904): The INSERT statement conflicted with the FOREIGN KEY constraint "FK_dbo.Individuals_dbo.Cities_CitieDeads_CitieId". The conflict occurred in database "C:\GENEALOGYTEST\MVCNOK\MVCNOK\APP_DATA\MVCNOKDB.MDF", table "dbo.Cities", column 'CitieId'.
The statement has been terminated.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +2442634
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5766568
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +285
System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +4162
System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() +58
System.Data.SqlClient.SqlDataReader.get_MetaData() +89
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption) +409
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest) +2031
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) +911
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +64
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +240
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +41
System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) +12
System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<Reader>b__c(DbCommand t, DbCommandInterceptionContext`1 c) +14
System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch(TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed) +72
System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext) +402
System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior) +166
System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) +12
System.Data.Entity.Core.Mapping.Update.Internal.DynamicUpdateCommand.Execute(Dictionary`2 identifierValues, List`1 generatedValues) +234
System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update() +159
[UpdateException: An error occurred while updating the entries. See the inner exception for details.]
System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update() +329
System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.<Update>b__2(UpdateTranslator ut) +11
System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update(T noChangesResult, Func`2 updateFunction) +132
System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update() +106
System.Data.Entity.Core.Objects.ObjectContext.<SaveChangesToStore>b__35() +13
System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction(Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess) +288
System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction) +157
System.Data.Entity.Core.Objects.<>c__DisplayClass2a.<SaveChangesInternal>b__27() +25
System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Func`1 operation) +162
System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction) +221
System.Data.Entity.Core.Objects.ObjectContext.SaveChanges(SaveOptions options) +11
System.Data.Entity.Internal.InternalContext.SaveChanges() +113
[DbUpdateException: An error occurred while updating the entries. See the inner exception for details.]
System.Data.Entity.Internal.InternalContext.SaveChanges() +191
System.Data.Entity.Internal.LazyInternalContext.SaveChanges() +27
System.Data.Entity.DbContext.SaveChanges() +22
MvcNOK.Controllers.IndividualsController.Create(Individual individual) in C:\GenealogyTest\MvcNOK\MvcNOK\Controllers\IndividualsController.cs:84
lambda_method(Closure , ControllerBase , Object[] ) +103
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +157
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +22
System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32
System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +50
System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +225
System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +26
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +36
System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9765121
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1586.0
Now I am using two different Id's to call up one for the individual living and individual dead Id from the same table.
This is differentiated in both controller and views javascript.
Now my Controller code is as follows:
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using IdentitySample.Models;
using MvcNOK.Models;
using System.Threading.Tasks;
namespace MvcNOK.Controllers
{
public class IndividualsController : Controller
{
private ApplicationDbContext db = new ApplicationDbContext();
// GET: Individuals
public ActionResult Index(string individualLast, string searchString)
{
var FirstList = new List<string>();
var FirstQry = from d in db.Individuals.Include(i => i.CitieDeads).Include(i => i.CitieLivings).Include(i => i.CountrieDeads).Include(i => i.CountrieLivings).Include(i => i.Genders).Include(i => i.StateDeads).Include(i => i.StateLivings)
orderby d.Last
select d.Last;
FirstList.AddRange(FirstQry.Distinct());
ViewBag.individualLast = new SelectList(FirstList);
var individuals = from m in db.Individuals
select m;
if (!String.IsNullOrEmpty(searchString))
{
individuals = individuals.Where(s => s.Given.Contains(searchString));
}
if (!string.IsNullOrEmpty(individualLast))
{
individuals = individuals.Where(x => x.Last == individualLast);
}
return View(individuals.ToList());
}
// GET: Individuals/Details/5
public ActionResult Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Individual individual = db.Individuals.Find(id);
if (individual == null)
{
return HttpNotFound();
}
return View(individual);
}
// GET: Individuals/Create
public ActionResult Create()
{
ViewBag.CitieDeadId = new SelectList(db.Cities, "CitieId", "Name");
ViewBag.CitieLivingId = new SelectList(db.Cities, "CitieId", "Name");
ViewBag.CountrieDeadId = new SelectList(db.Countries, "CountrieId", "Name");
ViewBag.CountrieLivingId = new SelectList(db.Countries, "CountrieId", "Name");
ViewBag.GenderId = new SelectList(db.Genders, "GenderId", "Name");
ViewBag.StateDeadId = new SelectList(db.States, "StateId", "Name");
ViewBag.StateLivingId = new SelectList(db.States, "StateId", "Name");
return View();
}
// POST: Individuals/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(Individual individual)
{
if (ModelState.IsValid)
{
db.Individuals.Add(individual);
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.CitieDeadId = new SelectList(db.Cities, "CitieId", "Name", individual.CitieDeadId);
ViewBag.CitieLivingId = new SelectList(db.Cities, "CitieId", "Name", individual.CitieLivingId);
ViewBag.CountrieDeadId = new SelectList(db.Countries, "CountrieId", "Name", individual.CountrieDeadId);
ViewBag.CountrieLivingId = new SelectList(db.Countries, "CountrieId", "Name", individual.CountrieLivingId);
ViewBag.GenderId = new SelectList(db.Genders, "GenderId", "Name", individual.GenderId);
ViewBag.StateDeadId = new SelectList(db.States, "StateId", "Name", individual.StateDeadId);
ViewBag.StateLivingId = new SelectList(db.States, "StateId", "Name", individual.StateLivingId);
return View(individual);
}
public JsonResult StateLivingList(int Id)
{
var state = from s in db.States
where s.CountrieId == Id
select s;
return Json(new SelectList(state.ToArray(), "StateId", "Name"), JsonRequestBehavior.AllowGet);
}
public JsonResult CitieLivinglist(int id)
{
var citie = from c in db.Cities
where c.StateId == id
select c;
return Json(new SelectList(citie.ToArray(), "CitieId", "Name"), JsonRequestBehavior.AllowGet);
}
public IList<State> GetstateLiving(int CountrieId)
{
return db.States.Where(m => m.CountrieId == CountrieId).ToList();
}
[AcceptVerbs(HttpVerbs.Get)]
public JsonResult LoadClassesByCountrieId(string Name)
{
var stateLivingList = this.GetstateLiving(Convert.ToInt32(Name));
var stateData = stateLivingList.Select(m => new SelectListItem()
{
Text = m.Name,
Value = m.CountrieId.ToString(),
});
return Json(stateData, JsonRequestBehavior.AllowGet);
}
public JsonResult StateDeadList(int Id)
{
var state = from s in db.States
where s.CountrieId == Id
select s;
return Json(new SelectList(state.ToArray(), "StateId", "Name"), JsonRequestBehavior.AllowGet);
}
public JsonResult CitieDeadlist(int id)
{
var citie = from c in db.Cities
where c.StateId == id
select c;
return Json(new SelectList(citie.ToArray(), "CitieId", "Name"), JsonRequestBehavior.AllowGet);
}
public IList<State> GetstateDead(int CountrieId)
{
return db.States.Where(m => m.CountrieId == CountrieId).ToList();
}
[AcceptVerbs(HttpVerbs.Get)]
public JsonResult LoadClassesByCountrieDeadId(string Name)
{
var stateDeadList = this.GetstateDead(Convert.ToInt32(Name));
var stateData = stateDeadList.Select(m => new SelectListItem()
{
Text = m.Name,
Value = m.CountrieId.ToString(),
});
return Json(stateData, JsonRequestBehavior.AllowGet);
}
// GET: Individuals/Create
public ActionResult Start()
{
ViewBag.CitieLivingId = new SelectList(db.Cities, "CitieId", "Name");
ViewBag.CountrieLivingId = new SelectList(db.Countries, "CountrieId", "Name");
ViewBag.GenderId = new SelectList(db.Genders, "GenderId", "Name");
ViewBag.StateLivingId = new SelectList(db.States, "StateId", "Name");
return View();
}
// POST: Individuals/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Start(Individual individual)
{
if (ModelState.IsValid)
{
db.Individuals.Add(individual);
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.CitieLivingId = new SelectList(db.Cities, "CitieId", "Name", individual.CitieLivingId);
ViewBag.CountrieLivingId = new SelectList(db.Countries, "CountrieId", "Name", individual.CountrieLivingId);
ViewBag.GenderId = new SelectList(db.Genders, "GenderId", "Name", individual.GenderId);
ViewBag.StateLivingId = new SelectList(db.States, "StateId", "Name", individual.StateLivingId);
return View(individual);
}
// GET: Individuals/Edit/5
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Individual individual = db.Individuals.Find(id);
if (individual == null)
{
return HttpNotFound();
}
ViewBag.CitieDeadId = new SelectList(db.Cities, "CitieId", "Name", individual.CitieDeadId);
ViewBag.CitieLivingId = new SelectList(db.Cities, "CitieId", "Name", individual.CitieLivingId);
ViewBag.CountrieDeadId = new SelectList(db.Countries, "CountrieId", "Name", individual.CountrieDeadId);
ViewBag.CountrieLivingId = new SelectList(db.Countries, "CountrieId", "Name", individual.CountrieLivingId);
ViewBag.GenderId = new SelectList(db.Genders, "GenderId", "Name", individual.GenderId);
ViewBag.StateDeadId = new SelectList(db.States, "StateId", "Name", individual.StateDeadId);
ViewBag.StateLivingId = new SelectList(db.States, "StateId", "Name", individual.StateLivingId);
return View(individual);
}
// POST: Individuals/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(Individual individual)
{
if (ModelState.IsValid)
{
db.Entry(individual).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.CitieDeadId = new SelectList(db.Cities, "CitieId", "Name", individual.CitieDeadId);
ViewBag.CitieLivingId = new SelectList(db.Cities, "CitieId", "Name", individual.CitieLivingId);
ViewBag.CountrieDeadId = new SelectList(db.Countries, "CountrieId", "Name", individual.CountrieDeadId);
ViewBag.CountrieLivingId = new SelectList(db.Countries, "CountrieId", "Name", individual.CountrieLivingId);
ViewBag.GenderId = new SelectList(db.Genders, "GenderId", "Name", individual.GenderId);
ViewBag.StateDeadId = new SelectList(db.States, "StateId", "Name", individual.StateDeadId);
ViewBag.StateLivingId = new SelectList(db.States, "StateId", "Name", individual.StateLivingId);
return View(individual);
}
// GET: Individuals/Delete/5
public ActionResult Delete(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Individual individual = db.Individuals.Find(id);
if (individual == null)
{
return HttpNotFound();
}
return View(individual);
}
// POST: Individuals/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)
{
Individual individual = db.Individuals.Find(id);
db.Individuals.Remove(individual);
db.SaveChanges();
return RedirectToAction("Index");
}
public async Task<ActionResult> RenderImage(int id)
{
Individual individual = await db.Individuals.FindAsync(id);
byte[] photoBack = individual.InternalImage;
return File(photoBack, "image/png");
}
public async Task<ActionResult> RenderImage1(int id)
{
Countrie countrie = await db.Countries.FindAsync(id);
byte[] photoBack = countrie.InternalImage;
return File(photoBack, "image/png");
}
public async Task<ActionResult> RenderImage2(int id)
{
State state = await db.States.FindAsync(id);
byte[] photoBack = state.InternalImage;
return File(photoBack, "image/png");
}
public async Task<ActionResult> RenderImage3(int id)
{
Citie citie = await db.Cities.FindAsync(id);
byte[] photoBack = citie.InternalImage;
return File(photoBack, "image/png");
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
db.Dispose();
}
base.Dispose(disposing);
}
}
}
My view code is as follows:
@model MvcNOK.Models.Individual
@using MvcNOK.Extensions
@{
ViewBag.Title = "Add a Person";
}
@Scripts.Render("~/bundles/jquery")
<script type="text/jscript">
$(function () {
$('#Countrie').change(function () {
$.getJSON('/Individuals/StateLivingList/' + $('#Countrie').val(), function (data) {
var items = '<option>Select a State</option>';
$.each(data, function (i, state) {
items += "<option value='" + state.Value + "'>" + state.Text + "</option>";
});
$('#State').html(items);
});
});
$('#State').change(function () {
$.getJSON('/Individuals/CitieLivinglist/' + $('#State').val(), function (data) {
var items = '<option>Select a City</option>';
$.each(data, function (i, citie) {
items += "<option value='" + citie.Value + "'>" + citie.Text + "</option>";
});
$('#citie').html(items);
});
});
});
</script>
@Scripts.Render("~/bundles/jquery")
<script type="text/jscript">
$(function () {
$('#Countrie1').change(function () {
$.getJSON('/Individuals/StateDeadList/' + $('#Countrie1').val(), function (data) {
var items = '<option>Select a State</option>';
$.each(data, function (i, state1) {
items += "<option value='" + state1.Value + "'>" + state1.Text + "</option>";
});
$('#State1').html(items);
});
});
$('#State1').change(function () {
$.getJSON('/Individuals/CitieDeadlist/' + $('#State1').val(), function (data) {
var items = '<option>Select a City</option>';
$.each(data, function (i, citie1) {
items += "<option value='" + citie1.Value + "'>" + citie1.Text + "</option>";
});
$('#citie1').html(items);
});
});
});
</script>
<br /><br /><br />
@using (Html.BeginForm("Create", "Individuals", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Add a Person</h4>
<p>
Use this page to add a person only if they have died already. It is also important that during your research to make sure the person you are adding, that all the information is correct including that the sources are correct. The reasons for this is because there will be no duplicates, the other reason is that some persons could have the same name but should be from different sources.
</p>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.Email, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Email, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Email, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Last, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Last, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Last, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Given, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Given, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Given, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.GenderId, "Gender", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownList("GenderId", null, htmlAttributes: new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.GenderId, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Occupation, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Occupation, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Occupation, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.DOB, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.DOB, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.DOB, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.CountrieLivingId, "Country", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-8">
@Html.DropDownList("CountrieLivingId", ViewBag.CountrieId as SelectList, "Select a Country", new { id = "Countrie1" })
@Html.ValidationMessageFor(model => model.CountrieLivingId, "", new { @class = "text-danger" })
</div><div class="col-lg-2">@Html.ActionLink("Add Country", "Create", "Countries")</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.StateLivingId, "State", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-8">
<select id="State1" name="state1"></select>
@Html.ValidationMessageFor(model => model.StateLivingId, "", new { @class = "text-danger" })
</div><div class="col-lg-2">@Html.ActionLink("Add State", "Create", "States")</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.CitieLivingId, "City", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-8">
<select id="citie1" name="citie1"></select>
@Html.ValidationMessageFor(model => model.CitieLivingId, "", new { @class = "text-danger" })
</div><div class="col-lg-2">@Html.ActionLink("Add City", "Create", "Cities")</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Source, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.Source, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Source, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Notes, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.Notes, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Notes, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.DOD, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.DOD, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.DOD, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.CountrieDeadId, "Country", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-8">
@Html.DropDownList("CountrieDeadId", ViewBag.CountrieId as SelectList, "Select a Country", new { id = "Countrie" })
@Html.ValidationMessageFor(model => model.CountrieDeadId, "", new { @class = "text-danger" })
</div><div class="col-lg-2">@Html.ActionLink("Add Country", "Create", "Countries")</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.StateDeadId, "State", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-8">
<select id="State" name="state"></select>
@Html.ValidationMessageFor(model => model.StateDeadId, "", new { @class = "text-danger" })
</div><div class="col-lg-2">@Html.ActionLink("Add State", "Create", "States")</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.CitieDeadId, "City", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-8">
<select id="citie" name="citie"></select>
@Html.ValidationMessageFor(model => model.CitieDeadId, "", new { @class = "text-danger" })
</div><div class="col-lg-2">@Html.ActionLink("Add City", "Create", "Cities")</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.DSource, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.DSource, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.DSource, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.DNotes, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.DNotes, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.DNotes, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.ItemPictureUrl, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.ItemPictureUrl, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.ItemPictureUrl, "", new { @class = "text-danger" })
</div>
</div>
<div class="editor-label">
Upload Image
</div>
<div class="editor-field">
@Html.FileFor(model => model.File)
@Html.ValidationMessageFor(model => model.File)
</div>
<br />
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Add Individual" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
Can anyone see what I am doing wrong?
Your help would be appreciated..
Thanks
A