1.
在後台定義個 protected 的變數 i=0;
2.
前台aspx
<asp:Repeater ID="repNewsHot" runat="server">
<HeaderTemplate>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="margin_bb">
<tr>
<td class="biaoti">
熱門話題
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td class='<%=(i++)<3 ? "CSSStyle1" : "CSSStyle2" %>' height="20px">
<a title='<%# DataBinder.Eval(Container.DataItem,"NewsTitle") %>' href='/News/ShowNewsDetails-<%# DataBinder.Eval(Container.DataItem, "NewsClassID")%>-<%# DataBinder.Eval(Container.DataItem, "NewsClassXID")%>-<%# UrlEncode(DataBinder.Eval(Container.DataItem, "newsID").ToString())%>.html'>
<img src='/images/LeftTop10/left<%=i %>.gif' align="absmiddle" />
<%# Left(DataBinder.Eval(Container.DataItem, "NewsTitle").ToString(),15) %>
</a>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
3.
圖片起名字 left1.gif.......left10.gif
that's all, it is very easy!