zoukankan      html  css  js  c++  java
  • DataList图片排版

    <asp:DataList ID="DataList2" runat="server" RepeatColumns="6"
            RepeatDirection="Horizontal">
            <ItemTemplate>
                <br />
               <a href='<%# "previewGoodWork.aspx?goodworkpicturepath="+DataBinder.Eval(Container.DataItem,"goodworkpicturepath") %>' OnCommand="ImageButton1_Command" ImageUrl='<%# Eval("goodworkpicturepath") %>' > <asp:Image ID="Image3" runat="server" ImageUrl='<%# Eval("goodworkpicturepath") %>' /></a>&nbsp;
                <br />
            </ItemTemplate>
        </asp:DataList>

    网页中:
    <ItemTemplate>
        <a href='' target="_blank" runat="server" id="vLnkImage">
            <asp:Image id="vImage" runat="server"></asp:Image>
        </a>
    </ItemTemplate>


    代码中:
    if(e.Item.ItemIndex > -1)
    {
        DataRowView drv = (DataRowView)e.Item.DataItem;
        System.Web.UI.WebControls.Image Img = (System.Web.UI.WebControls.Image)e.Item.FindControl("vImage");

        Img.ImageUrl = "/Images/+drv["c_FileName"].ToString();
       
        HtmlAnchor Link1 = (HtmlAnchor)e.Item.FindControl("vLnkImage");    
        Link1.HRef = "http://"+drv["c_URL"].ToString();
    }

    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();

  • 相关阅读:
    Bootstrap_警示框
    Bootstrap_标签
    Bootstrap_分页
    Bootstrap_导航条
    Bootstrap_导航
    Bootstrap_按钮工具栏
    Bootstrap_下拉菜单
    Bootstrap_网格系统
    Bootstrap_表单_图标
    统计学习方法 李航---第12章 统计学习方法总结
  • 原文地址:https://www.cnblogs.com/zzxap/p/2175945.html
Copyright © 2011-2022 走看看