前台:

<tr>
<asp:Repeater ID="rtpNewImgs" runat="server" onitemdatabound="rtpNewImgs_ItemDataBound" >
        <ItemTemplate>
                  <td>
                            <%# Container.ItemIndex +  + 1  %>                                      

                  </td>
         </ItemTemplate>
  </asp:Repeater>
 </tr>

 

后台:

protected int i=1;

protected void rtpNewImgs_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {
            //repter换行
            if (i % 2== 0 && i > 0)
            {
                e.Item.Controls.Add(new LiteralControl(" </tr> <tr> "));
            }
            i++;
        }
    }

posted on 2011-12-15 10:36  吴勇寿  阅读(2146)  评论(0编辑  收藏  举报