Guest User

Guest User

  • Tech Writer
  • 103
  • 13.3k

Set Card Using foreach.

May 14 2021 10:05 AM
How to display data using card with foreach.Please check this link
https://getbootstrap.com/docs/4.1/components/card/ 
 
and this is my code
<div class="container">
<div class="row">
@foreach (var blogPost in Model.Items)
{
<div class="col-md-4">
<div class="list-wrapper">
<div class="card shadow-sm border-light">
<a href="@blogPost.FullPath">
@if (blogPost.ThumbnailImageAsset != null)
{
<img src="~/Images/businessman-concept-illustration_114360-1246.jpg" />}
else
{
<img src="~/Images/businessman-concept-illustration_114360-1246.jpg" />
}
</a>
<div class="card-body">
<p class="card-title"><h>@blogPost.Title</h></p>
<p class="card-text">@blogPost.ShortDescription</p>
<a href="@blogPost.FullPath" class="read-more">Read More</a>
</div>
</div>
</div>
</div>
}
</div>
</div>
 

Answers (2)