I am new to MVC Razor please help me to implement this, I have MVC Razor view I need to implement Listing and editing in the same view In the view, there is a List which will list the records from a collection
@foreach (var item in Model.IncidentListmodel).
The list contains TextArea, Button for each record.
@Html.TextAreaFor(modelItem => item.Note, 2, 20, new { maxlength = 50 })
<input type="button" title="Save" value="Save" onclick="location.href='@Url.Action("Updateinc", "Incident", new { id = item.Id, name = item.Name, note = item.Note})'" />
My purpose is for each list item record, User should be able to edit the content which is populated in the Text area and modify the content and can save (that particular record) with the corresponding button.
More Details:
Below are the details of I am trying to implement Each list item contains a Text area (data listing here properly) and a button for each. While tap on the button the new content in the text area (which I modified from UI) should be updated (I can write the update code). But while taping on the button, after changing the content of text area, the controller it is getting the old value only.
View:
<table>
@foreach (var item in Model.IncidentListmodel)
{
string class1 = item.Id % 2 == 0 ? "orangeRaw" : "blueRaw";
<tr class="@class1">
<td>@Html.DisplayFor(modelItem => item.Name)</td>
<td>@Html.DisplayFor(modelItem => item.Title)</td>
<td>
@Html.TextAreaFor(modelItem => item.Note, 2, 20, new { maxlength = 50 })
</td>
<td>
<input type="button" title="Save" value="save" onclick="location.href='@Url.Action("Updateinc", "Incident", new { id = item.Id, name = item.Name, note = item.Note})'" />
</td>
</tr>
}
</table>
Controller:
public ActionResult Updateinc(int id,string name,string note,int? status )
{
return View();
}