日期:2014-05-17 浏览次数:20563 次
<table class="viewframe-body" title="">
<tbody class="dataBody">
<asp:Repeater ID="rptVideos" runat="server">
<ItemTemplate>
<%# GetStartTr(Container.ItemIndex) %>
<td class="media_list" width="25%" id="<%# Eval("SN") %>">
<div class="img_left"><a href="mediaView.aspx?<%# GetQueryString() %>"><img src="<%# mediaUrl + Eval("SnapSN").ToString() %>.jpg" alt="<%# Eval("Name") %>" title="<%# Eval("Name") %>" /></a></div>
<div class="media_list_title"><%# String.Format("【{0}】<br />{1}", Eval("Writer"), Eval("Name"))%></div>
</td>
<%# GetEndTr(Container.ItemIndex) %>
</ItemTemplate>
</asp:Repeater>
</tbody>
<tr class="viewframe-bottom">
<td colspan="4"><Kidtech:TurnPage ID="tpDatas" runat="server" /></td>
</tr>
</table>
protected string GetStartTr(int index)
{
if (index % 4 == 0) // 一行四列
return "<tr>";
return null;
}
protected string GetEndTr(int index)
{
if (index % 4 == 3)
return "</tr>";
if (index == totalRecord) // 记录数不可能是4的倍数,这里用空白补齐Table最后少的列
{
int padNum = 3 - (index % 4);
return "<td cols='" + padNum + "'></td></tr>";
}
return null;
}