我用下面的代码为Repeater作分行事件,就是到7列后就分一行,但有一些在分的时候却出现了一行不够7列的问题,想知道如何解决?
protected int ii = 1;
protected void repsitelist_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (ii % 7 == 0)
{
e.Item.Controls.Add(new LiteralControl("</tr><tr>"));
}
ii++;
}
protected int ii = 1;
protected void repsitelist_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (ii % 7 == 0)
{
e.Item.Controls.Add(new LiteralControl("</tr><tr>"));
}
ii++;
}
用x符号标识一下你的生成结果给大伙看看x x x x x x x
x x x
这样 protected void repsitelist_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if ((ii+1) % 7 == 0)
{
e.Item.Controls.Add(new LiteralControl("</td></tr><tr>"));
}
ii++;
}
<asp:Literal id="br" Visiable="false" runat="server" Text="<br />"></asp:Literal>然后在
protected void repsitelist_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if ((ii+1) % 7 == 0)
{
Literal t = e.Item.FindControl("") as Literal;
t.Visiable = true;
}
ii++;
}