我正在开发 MVC 应用程序。
我想在控制器中创建列表并将其传递给视图。
我已经在控制器中编写了该方法,但不知道如何在表单视图中调用它并显示它返回的值。
控制器中的方法。
public List<Invoice> GetInvoiceList(int Pid)
{
List<Invoice> Invoices = new List<Invoice>();
var InvoiceList = (from i in db.Invoices
where i.PaymentAdviceId == Pid
select i);
Invoices = InvoiceList.ToList();
return (Invoices);
}
查看代码
<div class="row-fluid">
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Advice No
</th>
<th>
Invoices
</th>
</tr>
</thead>
@foreach (var item in Model)
{
<tbody>
<tr>
<td>
@Html.DisplayFor(modelItem => item.AdviceNo)
</td>
I wan to call the controller method GetInvoiceList here and
want to display list items here...
<td>
</tr>
</tbody>