Show Image in Datatable Asp.net MVC

Asked

Viewed 93 times

0

I’m having trouble displaying an image in my application’s datatable. I get the name of the image but it does not display.

 "columns": [
                    { "data": "Id", "name": "Id", "autoWidth": true },
                    { "data": "Name", "name": "Name", "autoWidth": true },
                    { "data": "CPF", "name": "CPF", "autoWidth": true },
                    { "data": "City", "title": "City", "name": "ContactName", "autoWidth": true },
                    { "data": "Adress", "name": "Adress", "autoWidth": true },
                    { "data": "OcupnationName", "name": "OcupnationName", "autoWidth": true },
                    {
                        
                        "render": function (data, type, full, meta) {

                            return '<img src="'+ full.Picture +'" style="width:150px; height:150px;" />';
                           
                        }
                
                    },
                    {
                        "render": function (data, type, full, meta) {
                            return '<a class="btn btn-info" href="/Employee/Details/' + full.Id + '">Info</a>';
                        }
                    },
                    {
                        "render": function (data, type, full, meta) {
                            return '<a class="btn btn-info" href="/Employee/AddOrEdit/' + full.Id + '">Edit</a>';
                        }
                    },

                    {
                        data: null, render: function (data, type, row) {
                            return "<a href='#' class='btn btn-danger' onclick=DeleteData('" + row.Id + "'); >Delete</a>";
                        }
                    },

                ]

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

  • In the full.Picture should come alone /Content/Fotos/images.jpg, the ~ should quit because it is not rendered by the server but by javascript. You could try then full.Picture.substring(1)

  • Thanks was just this blessed "~" even, I did as you said and it worked.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.