Edit C # Item List

I want to update the list of elements on the edit page, the user proceeds to edit the page and updates the query for the list of questions, the model for the query is ready to use, edit.cshtml is similar to

@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 will it be managed?

public ActionResult Edit(List <Requesttable> requestlist)
    {//some logic here!}
+4
source share
1 answer

If I understand correctly, you want to see the controller. At first, I think something is 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 and don't forget to reorganize. My cod is not good practice, you do not install db inside the controller method.

+1
source

All Articles