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>

      

          </ItemTemplate> </asp:Repeater>

 

后台类似datalist。

posted on 2015-07-15 19:51  changyehappy  阅读(244)  评论(0编辑  收藏  举报

导航