简体   繁体   English

如何显示图像 <img> 名称存储在数据库中的标签

[英]how to display image in a <img> tag whose name is stored in database

I got the image name inserted in MS SQL Server database. 我在MS SQL Server数据库中插入了图像名称。 and the images should be displayed in a ListView , the question is how to append accurate image path to src attribute in code snippet below: 并且图像应显示在ListView ,问题是如何在下面的代码片段中向src属性附加准确的图像路径:

 <ItemTemplate>
      <div class="boxWrapper">
              <img src=<%#Eval("name") %> />
 </ItemTemplate> 

The way of concatenating additional string with eval statement is below: 用eval语句连接附加字符串的方法如下:

<img src='<%# "YOUR_DIRECTORY_PATH" + Eval("name") %>' />

Eg. 例如。

<img src='<%# "content/images/" + Eval("name") %>' />

This will fix your concern 这将解决您的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM