如何在ASP.NET C#中绑定数据列表以显示图像库 [英] how to bind datalist in asp.net c# to show image gallery

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

问题描述

如何在asp.net c#中绑定数据列表以显示图像库.我想在没有数据库帮助的情况下以动态方式在数据列表中显示图像.有人可以帮助我吗?

how to bind datalist in asp.net c# to show image gallery.i want to show images in datalist at dynamically without help of database.can anybody help me please

推荐答案

<asp:DataList ID="dtlist" runat="server" ForeColor="#333333" RepeatColumns="5">
<%-- <AlternatingItemStyle BackColor="White" ForeColor="#284775" />
          <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
          <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />--%>
          <ItemStyle BackColor="#F7F6F3" ForeColor="#333333" HorizontalAlign="Left"/>
             <ItemTemplate>
             <ul class="thumbs noscript">

                 <li>
                  <a class="thumb" href='<%# Eval("Name","images/portfolio_one/{0}")%>'>
                             <img src='<%# Eval("Name","images/portfolio_one/{0}")%>' width="80" height="90" alt='<%# Eval("Name") %>'/>
                           </a>
                   </li>
             </ul>
                   </ItemTemplate>
                      
             <SelectedItemStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /></asp:DataList>









protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindDataList();
        }
    }
    protected void BindDataList()
    {
        DirectoryInfo dir = new DirectoryInfo(MapPath("images/portfolio_one/"));
        FileInfo[] files = dir.GetFiles();
        ArrayList listItems = new ArrayList();
        foreach (FileInfo info in files)
        {
            listItems.Add(info);
        }
        dtlist.DataSource = listItems;
        dtlist.DataBind();

    
    }


尝试一下

尝试使用CSS,jquery来制作简单画廊

http://www.aspdotnet-suresh.com/2011/05/how-to-bind-images-from-folder-to.html [ http://www.4guysfromrolla.com/articles/081303-1.aspx [ ^ ]
try this

try to use make simple gallery using CSS,jquery

http://www.aspdotnet-suresh.com/2011/05/how-to-bind-images-from-folder-to.html[^]

http://www.4guysfromrolla.com/articles/081303-1.aspx[^]


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

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