我本人是转贴的,没测试过:
datalist的实现
protected
int
i
=
0
;
protected void DataList1_ItemDataBound( object sender, DataListItemEventArgs e)
{
i++;
if (i / 10 == 1)
{
e.Item.Controls.Add(new System.Web.UI.LiteralControl("</td></tr><tr width='100%'><td colspan='10' style='background-image:url(images/ClassSeparator.gif); background-repeat:repeat-x; height:3px; width:100%'></td></tr><tr><td>"));
}
if (i == 10)
{
i = 0;
}
}
注意:
RepeatDirection="Horizontal"
protected void DataList1_ItemDataBound( object sender, DataListItemEventArgs e)
{
i++;
if (i / 10 == 1)
{
e.Item.Controls.Add(new System.Web.UI.LiteralControl("</td></tr><tr width='100%'><td colspan='10' style='background-image:url(images/ClassSeparator.gif); background-repeat:repeat-x; height:3px; width:100%'></td></tr><tr><td>"));
}
if (i == 10)
{
i = 0;
}
}
repeater的实现
protected
int
i
=
0
;
protected void Repeater1_ItemDataBound( object sender, RepeaterItemEventArgs e)
{
if (i % 18 == 0)
{
e.Item.Controls.Add(new System.Web.UI.LiteralControl("</tr><tr>"));
}
i++;
}
protected void Repeater1_ItemDataBound( object sender, RepeaterItemEventArgs e)
{
if (i % 18 == 0)
{
e.Item.Controls.Add(new System.Web.UI.LiteralControl("</tr><tr>"));
}
i++;
}