Ich bin mit jquery Datentabelle v 1.10.12JQuery Datentabelle anzeigen Bild von SQL db
$(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 }
]
});
});
Ich habe Bild in SQL-Datenbank-Tabelle gespeichert. CustImage“ist varbinary in SQL.
db.Customers.OrderBy(a => a.Name).ToList();
Wie in Datentabelle Bild anzuzeigen?
"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})'/>';
}
}
]
Ausnahme auslöst, Der Name 'voll' existiert nicht im aktuellen Kontext
public FileContentResult imageGenerate(byte[] imgData)
{
if (imgData != null)
{
return new FileContentResult(imgData, "image/jpg");
}
return null;
}
http://www.w3schools.com/jsref/dom_obj_image.asp und http://stackoverflow.com/questions/10982712/convert-binary-data-to-base64-with-javascript – madalinivascu
können Sie bitte überprüfen Sie das "Rendern" in Spalten? –
Sie erkennen, dass Sie ajax tun Sie nicht, Sie versuchen, asp im Browser ausführen, die nicht möglich ist – madalinivascu