想要从SQL检索图像并使用Eval()在Listview中显示 [英] want to retrieve image from SQL and display in Listview using Eval()

查看:90
本文介绍了想要从SQL检索图像并使用Eval()在Listview中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,我想从数据库中检索图像并在asp.net的listview中显示。

但是我的图像在浏览器上加载页面时被破坏了。请指导我在这里做的错误。请尽快点亮我的问题。你的回答将不胜感激。在此先感谢...有关详细信息,请参阅下面的代码。

 <   div     class   =  column_w430 fl vl_divider >  

< span class =code-keyword>< asp:ListView ID = ListView1 runat = server DataKeyField = < span class =code-keyword> ID

< span class =code-attribute> DataSourceID = SqlDataSource1 >

< ItemTemplate >
< table >
< tr >

< td >

< asp:ImageButton ID = ImageButton1 runat = server

< span class =code-attribute> < span class =code-attribute> 高度 = 118px

< span class =code-attribute> ImageUrl =' <% #Eval( ImagePath)%>' 标题 =' <% #Eval( 标题)%>'

< span class =code-attribute> 宽度 = 170px / >


< / td >


< / tr >
< / table >

< / ItemTemplate >
< / asp:ListView >

< / div >



< asp:SqlDataSource ID =SqlDataSource1runat =server

ConnectionString =<%$ ConnectionStrings:BOLKASHMIRConnectionString%>

SelectCommand =SELECT [ID],[headlines],[ImagePath] FROM [Taza_Treen] ORDER BY [ID]>

解决方案

< blockquote> ConnectionStrings:BOLKASHMIRConnectionString%>

SelectCommand =SELECT [ID],[标题],[ImagePath] FROM [Taza_Treen] ORDER BY [ID]>


在您的数据库中,您可以拥有图像的相对或绝对路径,例如

 http://yourdomain.com/images/example.png 

images / example.png



检查ImagePath列中的值,并确保它具有以太有效绝对路径或有效相对路径。


Sir i want ro retrieve image from database and display in listview in asp.net.
but my images are broken while loading page on browser. please guide me what mistake i do here. please light on my problem as soon as possible. your answer will be appreciated. thanks in advance...for further detail please see my code below.

<div class="column_w430 fl vl_divider">
          
                <asp:ListView ID="ListView1" runat="server" DataKeyField="ID" 

                DataSourceID="SqlDataSource1">
                
                <ItemTemplate>
                <table>
                <tr>
                
                <td >
                 
                    <asp:ImageButton ID="ImageButton1" runat="server"

                                     Height="118px" 

                                    ImageUrl='<%# Eval("ImagePath")%>' headlines='<%# Eval("headlines")%>' 

                                     Width="170px" />
                
                
                               </td>
                             
                                
                               </tr>
                               </table>
                 
                </ItemTemplate>
                </asp:ListView>

                 </div>


<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:BOLKASHMIRConnectionString %>"
SelectCommand="SELECT [ID], [headlines], [ImagePath] FROM [Taza_Treen] ORDER BY [ID]">

解决方案

ConnectionStrings:BOLKASHMIRConnectionString %>"
SelectCommand="SELECT [ID], [headlines], [ImagePath] FROM [Taza_Treen] ORDER BY [ID]">


In your database you can have relative or absolute path for the images, for example

http://yourdomain.com/images/example.png

images/example.png


check the value in ImagePath column and make sure it has ether valid absolute path or valid relative path.


这篇关于想要从SQL检索图像并使用Eval()在Listview中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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