• asp.net中DataList和Repeater的使用


    DataList和Repeater是两个十分有用的控件,在新闻列表和图片展示的地方经常用到。在这里简单的把他们介绍一下。

    1.DataList:

    前端页面:

     <asp:DataList ID="PicList" runat="server" RepeatColumns="3" Width="90%" RepeatDirection="Horizontal">
                  <ItemStyle BorderWidth="0" BorderStyle="none" Width="200" HorizontalAlign="center" />
                  <ItemTemplate>
                        <table border="0" cellpadding="0" cellspacing="0" width="100%">
                            <tr>
                                <td height="110px">
                                    <img src='<%# Eval("IMGurl")  %>' width="174" height="130" alt="" style="cursor: hand;" />
                                </td>
                            </tr>
                            <tr>
                                <td align="center" height="40px">
                                    <asp:Label ID="Content" runat="server" Width="100%" Text='<%# Eval("IMGms")   %>' /></td>
                            </tr>
                        </table>
                  </ItemTemplate>
      </asp:DataList>

    属性介绍:RepeatColumns:在横向或书香重复的条数;

    RepeatDirection:重复方向。

    后台代码:

            this.PicList.DataSource = ds;
            this.PicList.DataBind();

    2.Repeater:使用方式更简单,

    <asp:Repeater ID="Repeater3" runat="server">
             <ItemTemplate>
                    <div align="left" class="divp1">
                           <img src="Images/jt.gif" width="10" height="11" alt="" />&nbsp;&nbsp;<a href='Talent.aspx?nurl=<%# Eval("MenuURL") %>' target="_blank"><strong><%# Eval("MenuName") %></strong></a>

          </div>
              </ItemTemplate>
    </asp:Repeater>

    后台类似datalist。

  • 相关阅读:
    Linux 文件查找
    Linux-Varnish缓存
    Linux-部署Hadoop环境
    Linux-部署MFS分布式文件系统
    Linux-部署Jumpserver跳板机
    Linux-部署Heartbeat高可用
    Linux-Mysql5.7之字段约束,索引,外键
    Linux-Mysql常用命令(下)
    Linux-Mysql常用命令(上)
    Python-常用模块详解
  • 原文地址:https://www.cnblogs.com/skyshenwei/p/1677114.html
Copyright © 2020-2023  润新知