如何在sql表中显示datalist中的图像 [英] How to display an image in datalist from sql table
本文介绍了如何在sql表中显示datalist中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从表'项
',我使用一个列名' picture_file
'来保存要显示的图像在datalist。
我使用以下代码。它没有错误或例外,但不显示图像。
From a table 'item
', I use a column name 'picture_file
' that holds images to be shown in datalist.
I use the following code. It works without errors or exception but image is not displayed.
<asp:DataList ID="Datalist1" runat="server" DataKeyField="item_code" RepeatDirection="Horizontal"
RepeatLayout="Table"
datasourceid="sqldatasource1">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
Item code:
<asp:Label Id="Itmcodelbl" runat="server" Text='<%#Eval("item_code") %>'>
</asp:Label>
<br />
Item Name:
<asp:Label Id="Itmnamelbl" runat="server" Text='<%#Eval("item_name") %>'>
</asp:Label>
<br />
详情:
Particulars:
<br />
<asp:TextBox Id="TB1" runat="server" Text='<%#Eval("item_desc") %>'
Height="94" ReadOnly="true" TextMode="MultiLine" BorderStyle="None">
</asp:TextBox>
<br />
<img src='<%# Eval("Picture_file") %>' style="height:100px;width:100px;border:1px
solid gray;"/>
<br />
</ItemTemplate>
</asp:DataList>
</table>
<asp:SqlDataSource ID="sqldatasource1" runat="server"
ConnectionString="<%$Connectionstrings:prassidhiConnectionString %>"
SelectCommand="SELECT [item_code], [item_name],[item_desc],[picture_file] FROM [item] ">
</asp:SqlDataSource>
<br />
</div
>
任何人都可以指导吗?
Can anyone guide?
推荐答案
Connectionstrings:prassidhiConnectionString%>
< span class =code-attribute> SelectCommand = SELECT [item_code],[item_name],[ item_desc],[picture_file] FROM [item] >
< / asp:SqlDataSource >
< ; br / < span class =code-keyword>>
< / div
>
Connectionstrings:prassidhiConnectionString %>" SelectCommand="SELECT [item_code], [item_name],[item_desc],[picture_file] FROM [item] "> </asp:SqlDataSource> <br /> </div >
任何人都可以指导吗?
Can anyone guide?
什么是值picture_file包含?
它应该保存为〜/ images / file.jpg而不是物理路径
what is the value picture_file contains?
It should be saved like ~/images/file.jpg not the physical path
我会建议你一步一步地按照这个链接。
希望这对你有帮助。
http://www.aspdotnetcodes.com/Insert_Images_Database.aspx [ ^ ]
I would suggest you to follow this link step by step.
Hope this will help you.
http://www.aspdotnetcodes.com/Insert_Images_Database.aspx[^]
这篇关于如何在sql表中显示datalist中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文