angelfallz says:
@Html.DisplayFor(modelItem => item.Content)
the way you are trying to display the image is wrong you need to use the img tag for displaying the image and you need to get the imageId from where it is getting binded that means you need to add one more property in your ImageViewModel that of name Id or your database column name after changing the model your model might look like below
ImageViewModel.cs
public class ImageViewModel
{
public string PetPhotoName { get; set; }
public byte[] Content { get; set; }
public int Id { get; set; } //Your Image PhotoId.
}
and your Index Action will look like below
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult Index()
{
ApplicationDbContext db = new ApplicationDbContext();
List<ImageViewModel> ImageViews = new List<ImageViewModel>();
var ImageList = (from cust in db.PetPhotoSS select new { cust.PetPhotoName, cust.Content, cust.Id }).ToList();
foreach (var item in ImageList)
{
ImageViewModel objcvm = new ImageViewModel();
objcvm.PetPhotoName = item.PetPhotoName;
objcvm.Content = item.Content;
objcvm.Id = item.Id; // Your DataBase ColumnName which containing the Id for the respective Image.
ImageViews.Add(objcvm);
}
return View(ImageViews);
}
and then you need to create a action method from where you can bind the image with its Id like below
public ActionResult RenderPhoto(int photoId)
{
byte[] photo = (new ApplicationDbContext()).PetPhotoSS.Find(photoId).Content;
return File(photo, "image/jpeg");
}
and your view with table format will look like below
<table>
<tr>
<th> @Html.DisplayNameFor(model => model.PetPhotoName)</th>
<th>
@Html.DisplayNameFor(model => model.Content)
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.PetPhotoName)
</td>
<td>
<img src="@Url.Action("RenderPhoto", "Home", new { photoId = item.Id })" width="100px" height="100px" alt="Pet Image" />
</td>
</tr>
}
</table>