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。

  • 相关阅读:
    面向对象诠释图
    vs中web网站和web应用程序的区别
    基于Windows Mobile 5.0的GPS应用程序开发
    c#添加水印效果
    基于Silverlight4开发的相关工具
    WCF、Net remoting、Web service概念及区别
    数据库的相关经验总结
    SQLite 3 一些基本的使用
    PPC上网设置明细图文并茂
    正则表达式语法参考
  • 原文地址:https://www.cnblogs.com/skyshenwei/p/1677114.html
Copyright © 2011-2022 走看看