Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I inserted image path into database and I want to retrieve that image into my view page. The table is binding with remaining columns but image is not displayed. How to display image in my WebGrid or Table.
I used this in my view page.
XML
@grid.GetHtml(columns:
    grid.Columns
    (
grid.Column("Id", "Id"),
grid.Column("Name","Name"),
grid.Column("Photo", format: @<text><img src="/Images/@item.Photo"  height="40px" width="40px" /></text>)

   )


Here Images is the Folder name and I am inserting dynamic image from folder.
I am using Asp.Net MVC with Entity Framework and SQL Server as Database
Thanks in Advance.
Posted
Updated 21-Nov-17 18:21pm
v2

1 solution

Do this way-
format: (item) =><br />
                 {<br />
                     return Html.Raw(string.Format("<text><img src="\"{0}\"" alt="\"Image\"" width="100px" height="100px" /></text>", Url.Content(@item.Photo)));<br />
                 }


Refer this tutorials-
http://mvc-model.blogspot.in/2013/07/how-to-bind-image-in-webgrid-using-mvc3.html[^]
http://www.aspdotnet-pools.com/2014/07/code-to-dynamicelly-bind-image-to.html[^]

-KR
 
Share this answer
 

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