2
Reply

mvc master detail help

erc ayd

erc ayd

Aug 12 2015 7:38 AM
485
i have a master detail form about patients and consultations
 
views/patients/edit.cshtml  contains
 
<div>
@Html.ActionLink("Back to List", "Index") |
@Html.ActionLink("Muayeneler", "Index", "Consultations", new { id = Model.ID }, new { @class = "adressLink" }) 
</div>
 
 consultationcontroller contains
 ----------------------------------------------------------------------
public ActionResult Index(int? id)
{
return View((from muayene in db.Muayeneler
where muayene.PersonId==id
select muayene).ToList<Muayeneler>());
}
// GET: Muayenelers/Details/5
public ActionResult Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Muayeneler muayeneler = db.Muayeneler.Find(id);
if (muayeneler == null)
{
return HttpNotFound();
}
return View(muayeneler);
}
// GET: Muayenelers/Create
public ActionResult Create(int? id)
{
return View();
}
// POST: Muayenelers/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([Bind(Include = "ID,MuayeneTarihi,PersonId,HastaFarkEtmis,DoktorMuayenesi,KitleSag,KitleSol,BasvuruSekli,Mammografi,TaramaMammografi,CiltteCekinti,Tarama,Sertlik,Mobil,Fikse,Eritem,PeauDorange,KoldaOdemCapi,KasaFiksasyon,SatellitNodul")] Muayeneler muayeneler)
{
if (ModelState.IsValid)
{
db.Muayeneler.Add(muayeneler);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(muayeneler);
}
---------------------------------------------------------------------
 views/consultations/create.cshtml contains
 
@model ContosoUniversity.Models.Constultation
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Muayeneler</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.MuayeneTarihi, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.MuayeneTarihi, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MuayeneTarihi, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.PersonId, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.PersonId, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.PersonId, "", new { @class = "text-danger" })
</div>
</div>
 
 
 I can not manage to pass the ID in the "views/patients/edit.cshtml " to the  PersonID of " views/consultations/create.cshtml "views  and insert the new detail record
  
 
can u please help me 
 
 
 
 
 

Answers (2)