I want to, pass the list of objects, from view to the controller's action.
My aim is, I will display, the list of all product's details. The user can able to edit any data (even all the data).
So after editing, I want to post, the entire list of the object, to controller's action, where I will decide something to continue on.
My sample code is:-
public class API_VM
{
public API_VM()
{
elemetnNames = new HashSet<string>();
}
public List<XElement> Stoklar { get; set; }
public HashSet<string> elemetnNames { get; set; }
public string PaketAgirligi { get; set; }
public string PaketGenisligi { get; set; }
public string PaketUzunlgu { get; set; }
public string PaketYuksekligi { get; set; }
public string StokAded { get; set; }
public string UrunAciklama { get; set; }
public string Kategori { get; set; }
public string UrunMarka { get; set; }
public string UrunAdi { get; set; }
public string UrunFiyat { get; set; }
public string UrunDil { get; set; }
public string SkuKodu { get; set; }
public string ServisPolitikaNo { get; set; }
public string KargoSablonID { get; set; }
public string StokAzaltmaStrateji { get; set; }
public string KargoyaVerilis { get; set; }
public string UrunFoto1 { get; set; }
public string UrunFoto2 { get; set; }
public string UrunFoto3 { get; set; }
public string UrunFoto4 { get; set; }
public string UrunFoto5 { get; set; }
public string UrunFoto6 { get; set; }
public string ParentElement { get; set; }
public string TedarikciLink { get; set; }
}
``
public class API_List:PageModel
{
[BindProperty]
public List<API_VM> ApiList { get; set; }
}
@model API_List
@{
ViewData["Title"] = "UrunlerListe";
Layout = "~/Views/Shared/_Layout.cshtml";
int i = 0;
}
<<form class="form-horizontal" method="post" asp-action="UrunPost">
<table class="table table-striped">
<tr>
<th>Product Name</th>
</tr>
@foreach (var item in Model.ApiList)
{
<tr>
<td>
<input type="text" asp-for="ApiList[i].UrunAdi" value="@item.UrunAdi" />
</td>
</tr>
}
</table>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Submit</button>
</div>
</div>
</form>
[HttpPost]
public IActionResult UrunPost(API_List model) */ Model is always null.
{
}

foreachbut then also aniyou never defined. I suspect you were intending to use aforbut didn't.