Reputation: 41
I wanna update a list of item in edit page, a user pass to edit page and update request for a list of question, a model for request is ready to use, edit.cshtml is like
@using (Html.BeginForm()){
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
@foreach (var item in Model.Requesttables)
{
<div class="editor-label">
@Html.LabelFor(modelItem => item.request)
</div>
<div class="editor-field">
@Html.EditorFor(modelItem => item.request)
@Html.ValidationMessageFor(modelItem => item.request)
</div>
<p>
<input type="submit" value="Save" />
</p>
}
</fieldset>
}
how the controler will be??
public ActionResult Edit(List <Requesttable> requestlist)
{//some logic here!}
Upvotes: 4
Views: 228
Reputation: 1567
If I understand it right, you want to see the controller. First I think that there is something wrong with your controller signature. It should be like this:
public ActionResult Edit(int id)
{
//search the object, no matter what it is - as long as it is form database by id
var db = new DbContext();
var yourRequestedList=db.Find(id); //or something like that, see linq for the correct sintax
yourRequestedList = objectThatWasEdited;
}
I hope this helps you out, and don't forget to refactor. My cod is not a good practice, you do not instatiate the db inside of a controller method.
Upvotes: 1