I want to add the images to the MVC project for datagrid!

I want to add the images to the MVC project for datagrid!

karunakhkarunakh Posts: 12Questions: 2Answers: 0
edited October 2017 in Free community support

I want to add the images to my MVC gridview project.
Please reply ASAP!

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,338Questions: 1Answers: 10,439 Site admin

    I'm not clear on how this relates to DataTables - could you clarify that please?

    Allan

  • karunakhkarunakh Posts: 12Questions: 2Answers: 0

    I am using datatables in my asp.net project with MVC framework, i have already done the responsive, pagination, searching, sorting and so on features but I also want to add photos that are already present in the database.Please reply if you need more information i can provide you.

  • allanallan Posts: 63,338Questions: 1Answers: 10,439 Site admin

    In what way are the photos in the database? Binary blobs or a text path to the image on the server? How do you normally view the images?

    Allan

  • karunakhkarunakh Posts: 12Questions: 2Answers: 0

    I am using Binary Blobs

  • allanallan Posts: 63,338Questions: 1Answers: 10,439 Site admin

    Okay, so its still not really a DataTables question. How would you normally get them out of the database for display in a browser (e.g. how would you do it without DataTables)? You'll probably need to have a script on your server-side that you sent an image id to, it will read the binary from the database and then feed it back to the client-side.

    Allan

  • karunakhkarunakh Posts: 12Questions: 2Answers: 0

    Hi, allan
    I am working on responsive grid using datatables and that is based on MVC , I am using
    "render": function (data, type, JsonResultRow, meta) {
    return '<img src="Content/images' + JsonResultRow.ImageAddress + '">';
    to retrive the photos that are already in my database( and I am working with the existing database in my company so, firstly they made a grid that was jqgrid and now the database is same but I am just adding that with ADO entity in the MVC project)
    but not getting anything, and this is the last step so, I need your help.
    so, far I follow this tutorial, if that helps you to understand my question:
    https://www.youtube.com/watch?v=2HliDQ4bfIA
    Please reply.

  • allanallan Posts: 63,338Questions: 1Answers: 10,439 Site admin

    "Content/images' + JsonResultRow.ImageAddress + '"

    What does that result in? What is JsonResultRow.ImageAddress?

  • karunakhkarunakh Posts: 12Questions: 2Answers: 0

    ImageAddress

  • karunakhkarunakh Posts: 12Questions: 2Answers: 0

    may be this is not right code which I am using

  • karunakhkarunakh Posts: 12Questions: 2Answers: 0

    result shows noting but disturbs my whole code the grid stopped working when i put these lines in

  • allanallan Posts: 63,338Questions: 1Answers: 10,439 Site admin

    If you link to the page I would be happy to take a look and help to debug it.

    Allan

  • karunakhkarunakh Posts: 12Questions: 2Answers: 0

    I wish I could post that code for you but can you please tell me is there any way to add the images from sql database to the MVC project.

  • allanallan Posts: 63,338Questions: 1Answers: 10,439 Site admin
    Answer ✓

    Assuming you have a URL to the image you can use columns.render:

        "render": function ( data, type, row, meta ) {
          return '<img src="'+JsonResultRow.ImageAddress+'" />';
        }
    

    If it isn't a URL to the image, then I don't know what it is and can't help without a test case.

    Allan

  • karunakhkarunakh Posts: 12Questions: 2Answers: 0

    thanks Allan it worked.

This discussion has been closed.