I have assigned a list to ViewBag
as below.
this is the code ...
var cer = tac.getAwards(hotelLocID);
List<Certificates> allcertificates = new List<Certificates>();
foreach (var items in cer)
{
allcertificates.Add(new Certificates
{
certifyimageurllarge = items.awardimage.largeimage,
certifyimageurlsmall = items.awardimage.smallimage,
certifyimageurltiny = items.awardimage.tinyimage,
awardedyear = items.year,
awardtype = items.awardtype
});
}
ViewBag.certificates = allcertificates;
in here allcertificates
list count is 2.but I want to show only first one in the View
.this is my view
@foreach(var items in @ViewBag.certificates)
{
<div class="row" style="padding-left:3%;">
<div class="col-md-2 col-xs-2"><img class="img img-responsive" src="@items.certifyimageurltiny" /></div><div class="col-md-6 col-xs-8" style="margin-left:-6%;padding-top:2%;">@items.awardtype | @items.awardedyear</div>
</div>
}
How can I do that.