Hi,
I need to update in mvc. I am sending the id but how do I send the other parameters. Is there a way to this? I am sharing my codes. Can you make an example based on my codes?
I tried form collection and failed. I will send multiple parameters.
View
@using EXProject.Models
@{
ViewBag.Title = "";
}
@foreach (var item in Model)
{
using (Html.BeginForm())
{
<form method="post">
<div class="row" style="margin-right:0px; margin-left:0px;">
<div class="col-md-6">
<!-- HTML5 Inputs -->
<div class="card mb-4">
<h5 class="card-header">HTML5 Inputs</h5>
<div class="card-body">
<div class="mb-3 row">
<label for="html5-month-input" class="col-md-2 col-form-label">Departman</label>
<div class="col-md-10">
<input class="form-control" type="text" value="@item.Department" name="departman" />
</div>
</div>
<div class="mb-3 row">
<label for="html5-month-input" class="col-md-2 col-form-label">Hakkında</label>
<div class="col-md-10">
<textarea class="form-control" name="hakkinda" value="@item.About" rows="3" multiple id="inputEmail4"></textarea>
</div>
</div>
<div class="mb-3 row">
<label for="html5-month-input" class="col-md-2 col-form-label">Başvuru Tarihi</label>
<div class="col-md-10">
<input class="form-control" type="text" value="@item.ApplicationDate" name="btarihi" />
</div>
</div>
<div class="mb-3 row">
<label for="html5-month-input" class="col-md-2 col-form-label">Not</label>
<div class="col-md-10">
<textarea class="form-control" name="note" rows="3" multiple id="inputEmail4"></textarea>
</div>
</div>
<div class="mb-3 row">
<label for="html5-month-input" class="col-md-2 col-form-label">Arşiv</label>
<div class="col-md-10">
<input class="form-check-input" type="checkbox" name="check" id="inlineCheckbox1" value="option1">
<label class="form-check-label" for="inlineCheckbox1">Arşive Yolla</label>
</div>
</div>
<div class="mb-3 row">
<label for="html5-month-input" class="col-md-2 col-form-label">CV</label>
<div class="col-md-7">
<input class="form-control" type="text" value="@item.CV" name="cv" />
</div>
<div class="col-md-3">
<a type="button" href="@Html.ActionLink("Download", "Job", new { file = item.CV })" class="btn rounded-pill btn-dark bx-pull-right">
Cv indir
</a>
<a href="~/Job/Download?file=@item.CV">İndir</a>
</div>
</div>
<br /><br />
<div class="mb-3 row">
<label for="html5-month-input" class="col-md-2 col-form-label">Güncelle</label>
<div class="col-md-10">
<a type="submit" href="@Url.Action("Guncelle", "Job", new { id = item.ID })" class="btn rounded-pill btn-success bx-pull-left">
Güncelle
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
}
}
Controller
public ActionResult Update(int id)
{
var job = context.JobApplication.Where(x => x.ID == id).FirstOrDefault();
job.Archive = "";
job.Note = "";
context.SaveChanges();
return View();
}