zoukankan      html  css  js  c++  java
  • 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。

  • 相关阅读:
    C++实现base64编码
    php实现base64编码
    美团2016研发工程师笔试题(绑鞋带问题)
    URL encode 与 URL decode 的C语言实现
    常用排序算法集合-C实现
    用文件实现计算器要求多进程同时写
    vim操作命令-笔记
    Can't connect to local MySQL server through socket
    小程序页面跳转数据丢失
    Vue路由 --登录状态的判断
  • 原文地址:https://www.cnblogs.com/skyshenwei/p/1677114.html
Copyright © 2011-2022 走看看