Hi @JUAN MIGUEL C. NIETO ,
I tested your controller code and it works fine. Based on your current information, it is not clear where your problem is.
I wrote a working example based on your current code, you can check it yourself, where is the problem.
Model
public class Excel1
{
public int ID { get; set; }
public string FileN { get; set; }
public string FilePath { get; set; }
public List<Excel1> lstExcel { get; set; }
}
Data.cshtml
@model WebApplication5.Models.Excel1
<h2>Data</h2>
@foreach (var products in Model.lstExcel)
{
<h3><u>@products.FileN</u></h3>
}
Controller
public ActionResult Data()
{
Excel1 products = GetProducts();
ViewBag.Message = "";
return View(products);
}
[HttpPost]
public ActionResult Data(Excel1 obj)
{
Excel1 products = GetProducts();
return View(products);
}
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.