Datalist调用本地文件绑定图片

<asp:DataList ID="dList1" runat="server" RepeatColumns="4">
    <ItemTemplate>
 
    <asp:Image runat="server" ID="img1" ImageUrl='<%# Eval("Name","~/Images/{0}") %>' Width="50px" Height="40px" name="imgA" />

   
    <img src="images/aa.jpg" width="50px" height="40px" onclick="show()" name="imgB"/>
  
    </ItemTemplate>
    </asp:DataList>

后台

  string path =MapPath("~/Images/");
       DirectoryInfo dir = new DirectoryInfo(path);

       dList1.DataSource = dir.GetFiles();
       dList1.DataBind();

posted @ 2008-01-16 19:52  思然  阅读(670)  评论(0编辑  收藏  举报