I am using jquery datatable v 1.10.12
$(function () {
$('.datatable-basic').DataTable({
"ajax": {
"url": "/Master/loadData",
"type": "GET",
"datatype": "json"
},
"columns": [
{ data: "Id", "autoWidth": true },
{ data: "Name", "autoWidth": true },
{ data: "CustImage", "autoWidth": true }
]
});
});
I have stored image in sql db table. CustImage" is varbinary in sql.
db.Customers.OrderBy(a => a.Name).ToList();
How to display image in datatable?
"columns": [
{ data: "Id", "autoWidth": true },
{ data: "Name", "autoWidth": true },
{
"render": function (data, type, full, meta) {
return '<img id="image" src='@Url.Action("imageGenerate", "Master", new { imgData = full.CustImage})'/>';
}
}
]
Throws exception, The name 'full' does not exist in the current context
public FileContentResult imageGenerate(byte[] imgData)
{
if (imgData != null)
{
return new FileContentResult(imgData, "image/jpg");
}
return null;
}