如何使用HTML中的变量后面的代码从数据库访问图像 [英] How to access image from data base using code behind variable in HTML
问题描述
这是我在aspx文件中的代码
<%= tours_post%>
<% - < table>< tr>< td>
< img>
< / div>
< h3>< / h3>
< p>< / p>
< / td>< / tr>< / table> - - %>
这是cs文件中的代码
tours_post + =< img> + dt_tours1.Rows [1] [1] +< / img>
+
< h3> + dt_tours1.Rows [1] [2] +< / h3> +
< p> + dt_tours1.Rows [1] [3] +< / p>;
我可以访问< h3>和< p>标签,但如何从数据库中获取图像。
This is my code in aspx file
<%=tours_post%>
<%--<table><tr><td>
<img>
</div>
<h3></h3>
<p></p>
</td></tr></table>--%>
This is the code in cs file
tours_post+= "<img>" + dt_tours1.Rows[1][1] + "</img>"
+
"<h3>" + dt_tours1.Rows[1][2] + "</h3>" +
"<p>" + dt_tours1.Rows[1][3] + "</p>";
I can access <h3> and <p> tag but how to get image from database.
推荐答案
为什么让它变得复杂?
你我相信已经拥有包含所有图像的DataTable。因此,只需将其绑定到GridView或DataList或Repeater。
Why are you making it complex?
You already have the DataTable with all the image, I believe. So, just bind that to a GridView or DataList or Repeater.
如果您的数据表包含图像URL,那么您应该尝试这样的事情:
If your datatable consists image url, then you should try something like this:
tours_post+= "<img src="" + dt_tours1.Rows[1][1] + "" />"
+
"<h3>" + dt_tours1.Rows[1][2] + "</h3>" +
"<p>" + dt_tours1.Rows[1][3] + "</p>";
&n bsp; - Amy
--Amy
我正在使用javascript设计一个轮播并从数据库中检索数据。我能够使用< img>+ dt_tours1.Rows [1] [1] +< / img>获得h3和p,只显示图像名称,但不显示图像。
I am designing a carousel using javascript and retriving data from data base. I am able to get h3 and p using <img>" + dt_tours1.Rows[1][1] + "</img>" only the name of image appears, but not the image.
这篇关于如何使用HTML中的变量后面的代码从数据库访问图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!