Вам нужно изменить местоположение формы, вот рабочая демонстрация, как показано ниже:
1.Модель:
public class Auto
{
public int AutoId { get; set; }
public string AutoType { get; set; }
public string AutoMake { get; set; }
public string AutoModel { get; set; }
public string AutoYear { get; set; }
public int StockLevel { get; set; }
public IList<AutoFeature> AutoFeature { get; set; }
}
public class AutoFeature
{
public string FeatureDescription { get; set; }
}
2.Просмотр:
@model IEnumerable<Auto>
<div id="InventoryGrid" class="container hiddenGrid">
<div class="row">
<table id="autosTable" class="table table-striped text-center">
<thead class="table-dark">
<tr>
//...
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>@Html.DisplayFor(modelItem => item.AutoType)</td>
<td>@Html.DisplayFor(modelItem => item.AutoMake)</td>
<td>@Html.DisplayFor(modelItem => item.AutoModel)</td>
<td>@Html.DisplayFor(modelItem => item.AutoYear)</td>
<td>
//...
</td>
<td>@item.StockLevel</td>
<td class="calculatedMarkup"></td>
<td width="300">
<form asp-action="UpdateInventory" method="post" class="container">
<input name="id" type="text" value="@item.AutoId" class="w-25" />
<input name="qty" type="number" min="1" max="@(Html.DisplayFor(modelItem=> item.StockLevel))" class="fomr-control w-25" />|
<input type="submit"
class="btn btn-sm btn-danger"
value="Remove" />
</form>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
3.Контроллер:
public IActionResult Index()
{
var model = new List<Auto>()
{
new Auto()
{
AutoId=1,AutoType="a1",AutoMake="b1",AutoModel="c1",StockLevel=3,
AutoFeature=new List<AutoFeature>(){ new AutoFeature() { FeatureDescription = "af1" } }
},
new Auto()
{
AutoId=2,AutoType="a2",AutoMake="b2",AutoModel="c2",StockLevel=5,
AutoFeature=new List<AutoFeature>(){ new AutoFeature() { FeatureDescription = "af2" } }
},
new Auto()
{
AutoId=3,AutoType="a3",AutoMake="b3",AutoModel="c3",StockLevel=7,
AutoFeature=new List<AutoFeature>(){ new AutoFeature() { FeatureDescription = "af3" } }
}
};
return View(model);
}
[HttpPost]
public IActionResult UpdateInventory(int id, int qty)
{
//do your stuff..
return RedirectToAction("Index");
}
Результат: