-1
This is my Viewbag
public ActionResult Details(AzureDiscountGroupModel model)
{
var reseller = _resellerService.QueryAll();
ViewBag.DetailReseller = reseller.Where(x => x.AzureDiscountGroupId == model.Id);
return View(model);
}
And how I get these fields in cshtml and populate a Grid(table) of type?
<h2>Details</h2>
<div>
<h4>AzureDiscountGroup</h4>
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.Descricao)
</dt>
<dd>
@Html.DisplayFor(model => model.Descricao)
</dd>
<dt>
@Html.DisplayNameFor(model => model.PercDesconto)
</dt>
<dd>
@Html.DisplayFor(model => model.PercDesconto)
</dd>
</dl>
</div>
<table class="table">
<tr>
<th>
@Html.DisplayName("Nome")?????
</th>
<th>
@Html.DisplayName("Desc")??????
</th>
<th></th>
</tr>
@foreach (var item in ViewBag.DetailReseller)
{
<tr>
<td>
@Html.Display(item.Name)???????????
</td>
<td>
@Html.DisplayFor(modelItem => item.PercDesconto)???????????
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
@Html.ActionLink("Details", "Details", new { id = item.Id }) |
@Html.ActionLink("Delete", "Delete", new { id = item.Id })
</td>
</tr>
}
</table>
<p>
@Html.ActionLink("Back to List", "Index")
</p>
EDIT1
I did that and it’s coming empty the table
@foreach (var item in ViewBag.DetailReseller as IEnumerable<Reseller>)
{
<tr>
<td>
@Html.Display(item.Name)
</td>
<td>
@Html.Display(item.Alias)
</td>
@*<td>
@Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
@Html.ActionLink("Details", "Details", new { id = item.Id }) |
@Html.ActionLink("Delete", "Delete", new { id = item.Id })
</td>*@
</tr>
}
Are you sure that the
reseller.Where()
does not carry an empty collection?– Victor Laio
@Victorlaio, I do have.
– pnet
The problem is that it is coming yes, the records in my case 10, but I can not display on the screen like this:
@Html.Display(item.Descricao)
for example– pnet