如何在网格中显示图像或mvc中的表格作为路径格式插入数据库? [英] How to display image in Web grid or Table in mvc which is inserted into Database as path format?

查看:82
本文介绍了如何在网格中显示图像或mvc中的表格作为路径格式插入数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我将图像路径插入数据库,我想将该图像检索到我的视图页面。该表与剩余列绑定,但不显示图像。如何在我的WebGrid或表中显示图像。

我在我的视图页面中使用了这个。

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.

@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>)

   )





这里的图像是文件夹名称,我从文件夹插入动态图像。

我使用的是Asp.Net带有实体框架和SQL Server作为数据库的MVC

先谢谢。



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.

推荐答案

这样做 -

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 />
                 }





参考本教程 -

h ttp://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



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


这篇关于如何在网格中显示图像或mvc中的表格作为路径格式插入数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆