Reputation: 809
I have a Dictionary containing some values into it. I want to render this values using table But I already have one table that is coming from other Model.This model containing the Dictionary I want to populate the Dictionary values into the table.
public class UnPaidChargesByStockRequestVM {
public int? SalvageId { get; set; }
public string Culture_Code { get; set; }
public List<UnPaidChargesByStockResponseVM> GetResuestModel;
}
public class UnPaidChargesByStockResponseVM {
public int? buyer_id { get; set; }
public int? stockNo { get; set; }
public Dictionary<string, decimal?> SalvageBuyerFees { get; set; }
}
This SalvageBuyerFees having some values into it.I want to display it on view. My View
@model BuyerPaymentMockUI.Web.Models.UnPaidChargesByStockRequestVM
<table class="table-bordered">
<thead>
<tr>
<th>buyer_id</th>
<th>stockNo </th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.GetResuestModel) {
<tr>
<td>@item.buyer_id</td>
<td>@item.stockNo</td>
</tr>
}
</tbody>
</table>
Now i want to display the SalvageBuyerFees values as well
Upvotes: 1
Views: 1868
Reputation: 118957
The simplest way is to use a nested foreach
loop:
@model BuyerPaymentMockUI.Web.Models.UnPaidChargesByStockRequestVM
<table class="table-bordered">
<thead>
<tr>
<th>buyer_id</th>
<th>stockNo </th>
<th>SalvageBuyerFees key</th>
<th>SalvageBuyerFees value</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.GetResuestModel) {
foreach (var sbf in item.SalvageBuyerFees {
<tr>
<td>@item.buyer_id</td>
<td>@item.stockNo</td>
<td>@sbf.Key</th>
<td>@sbf.Value</th>
</tr>
}
}
</tbody>
</table>
Upvotes: 2