asp.net mvc - How to render the Dictionary values in the table in MVC -
i have dictionary containing values it. want render values using table have 1 table coming other model.this model containing dictionary want populate dictionary values 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 values it.i want display on view. 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 want display salvagebuyerfees values well
the simplest way use 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>
Comments
Post a Comment