在数据库的数据列表中显示图像 [英] Display Image in Datalist from Database

查看:73
本文介绍了在数据库的数据列表中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何显示来自数据库的数据列表中的图像以及其他数据.

我需要在DataList中显示IdTitledescriptionImage.

Hi,

How I can display Image in datalist from databases with other data.

I need to display Id, Title, description and Image in DataList.

select Id, Title, Date, DataDescription, Img from Table1


我想这样


I am trying like this

<asp:DataList ID="ddl" runat="server" Width="100%" RepeatDirection="Horizontal"

                        RepeatColumns="1" ItemStyle-HorizontalAlign="Center" BackColor="White" BorderColor="#999999"

                        BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical" OnItemCommand="ddl_ItemCommand">
                        <AlternatingItemStyle BackColor="#DCDCDC" />
                        <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
                        <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
                        <ItemStyle HorizontalAlign="Center" BackColor="#EEEEEE" ForeColor="Black"></ItemStyle>
                        <ItemTemplate>
                            <div class="developmentblock">
                                <div class="titleblock">
                                    <%# Eval("Title")%></div>
                                <div class="testi_right_development">
                                    <div class="text_desc" style="width: 700px; height: 100px">
                                        <%# Eval("Description")%>
                                    </div>
                                    <div class="more_post" style="width: 700px" align="Right">
                                        <asp:Label ID="lblName" runat="server" Text='<%# Eval("Date")%>'></asp:Label>
                                    </div>
                                </div>
                                <div class="imagecontainer_development">
                                    <asp:Image ID="Image1" runat="server" Width="110px" Height="120px" ImageUrl='<%#DataBinder.Eval(Container.DataItem, "Img") %>' GenerateEmptyAlternateText="True" />

                                        </div>
                            </div>
                        </ItemTemplate>
                        <SelectedItemStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
                    </asp:DataList>





和代码隐藏绑定是这样的:





and code-behind binding is like this:

ddl.DataSource = dt;
 ddl.DataBind();




在此先感谢
Kuldeep Dwivedi




Thanks in Advance
Kuldeep Dwivedi

推荐答案

Image控件期望文件的物理源来自数据库.在这种情况下,通常创建一个HTTP处理程序以从数据库中提取图像并将其流式传输到浏览器.
The Image control expects a physical source for the file which you don''t have coming from the database. In these situations it is typical to create a HTTP Handler to extract the image from the database and stream it to the browser.


嘿!
解决了...

请点击此链接.

http://www.aspdotnetcodes.com/Insert_Images_Database.aspx [
Hey!
It''s resolved ...

Follow this link.

http://www.aspdotnetcodes.com/Insert_Images_Database.aspx[^]

Thanks
Kuldeep Dwivedi


将帮助您...

ASP.NET中的图像处理 [
Will help you...

Image Handling In ASP.NET[^]


这篇关于在数据库的数据列表中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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