Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an image table with several images and the image type is varchar(max)
Model:
namespace EquipmentInventory.Models
{
using System;
using System.Collections.Generic;

public partial class Image
{
public int ImageID { get; set; }
public string ImageName { get; set; }
public string ImageData { get; set; }
public Nullable<int> EquipmentID { get; set; }

public virtual Equipment Equipment { get; set; }
}
}
View:
@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.ImageName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.ImageData)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Equipment.Company)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.ImageID }) |
            @Html.ActionLink("Details", "Details", new { id=item.ImageID }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.ImageID })
        </td>
    </tr>


Controller:
namespace EquipmentInventory.Controllers
{
    public class ImagesController : Controller
    {
        private InventoryEntities db = new InventoryEntities();

        // GET: Images
        public ActionResult Index()
        {
            var images = db.Images.Include(i => i.Equipment);
            return View(images.ToList());
        }


When I run this in the ImageData field I get a HUGE string of random characters rather than the actual image.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900