Reapter分列
时间:2010-11-29 来源:blair0807
代码
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="12title" ID="Table5">
<asp:repeater id="rptList1" runat="server">
<ItemTemplate>
<tr>
<td width="55%" valign="top" height="20">
·<a href='<%#((DataRowView)Container.DataItem)["newsurl"]%>'class="link14" target="_blank"><%#((DataRowView)Container.DataItem)["newsline"]%></a>
</td>
</ItemTemplate>
<AlternatingItemTemplate>
<td width="55%" valign="top" height="20">
·<a href='<%#((DataRowView)Container.DataItem)["newsurl"]%>'class="link14" target="_blank"><%#((DataRowView)Container.DataItem)["newsline"]%></a>
</td>
</tr>
</AlternatingItemTemplate>
</asp:repeater>
</table>
<tr><ASP:Repeater id="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">
<ItemTemplate>
<td width="103">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr height="60">
<td align="center" style="width: 100px"><a href="<%# DataBinder.Eval(Container.DataItem,"Links") %>"><img src="../uploadfiles/UploadFile/<%# DataBinder.Eval(Container.DataItem,"Pic") %>" alt="<%# DataBinder.Eval(Container.DataItem,"Name") %>" width="46" height="46" border="0"></a></td>
</tr>
<tr height="22">
<td align="center" style="width: 100px"><a href="<%# DataBinder.Eval(Container.DataItem,"Links") %>" class="a2" target="main"><%# DataBinder.Eval(Container.DataItem,"Name") %></a></td>
</tr>
</table>
</td>
</ItemTemplate></ASP:Repeater>
</tr>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
PersTools persTools = new PersTools();
DataTable dt = persTools.GetPersToolsInfos(string.Empty);
this.Repeater1.DataSource = dt;
this.Repeater1.DataBind();
}
}
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (i % 6 == 0)//6是一行显示列数
{
e.Item.Controls.Add(new LiteralControl("</tr><tr>"));
}
i++;//
}
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="12title" ID="Table5">
<asp:repeater id="rptList1" runat="server">
<ItemTemplate>
<tr>
<td width="55%" valign="top" height="20">
·<a href='<%#((DataRowView)Container.DataItem)["newsurl"]%>'class="link14" target="_blank"><%#((DataRowView)Container.DataItem)["newsline"]%></a>
</td>
</ItemTemplate>
<AlternatingItemTemplate>
<td width="55%" valign="top" height="20">
·<a href='<%#((DataRowView)Container.DataItem)["newsurl"]%>'class="link14" target="_blank"><%#((DataRowView)Container.DataItem)["newsline"]%></a>
</td>
</tr>
</AlternatingItemTemplate>
</asp:repeater>
</table>
分N列:
前台代码
<tr><ASP:Repeater id="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">
<ItemTemplate>
<td width="103">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr height="60">
<td align="center" style="width: 100px"><a href="<%# DataBinder.Eval(Container.DataItem,"Links") %>"><img src="../uploadfiles/UploadFile/<%# DataBinder.Eval(Container.DataItem,"Pic") %>" alt="<%# DataBinder.Eval(Container.DataItem,"Name") %>" width="46" height="46" border="0"></a></td>
</tr>
<tr height="22">
<td align="center" style="width: 100px"><a href="<%# DataBinder.Eval(Container.DataItem,"Links") %>" class="a2" target="main"><%# DataBinder.Eval(Container.DataItem,"Name") %></a></td>
</tr>
</table>
</td>
</ItemTemplate></ASP:Repeater>
</tr>
后台代码
protected int i = 1;protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
PersTools persTools = new PersTools();
DataTable dt = persTools.GetPersToolsInfos(string.Empty);
this.Repeater1.DataSource = dt;
this.Repeater1.DataBind();
}
}
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (i % 6 == 0)//6是一行显示列数
{
e.Item.Controls.Add(new LiteralControl("</tr><tr>"));
}
i++;//
}
相关阅读 更多 +