一、下面的代碼實現,每行顯示三列
前台代碼:
<table>
<tr>
<ASP:repeater id="repeater1" runat="server">
<itemtemplate>
<td><%#databinder.eval(container.dataitem,"thing")%></td>
</itemtemplate>
</ASP:repeater>
</tr>
</table>
後台代碼:
protected int i=1;
private void page_load(object sender, system.eventargs e)
{
xmlserializer ser = new XMLserializer(typeof(dataset));
dataset ds = new dataset("mydataset");
datatable t = new datatable("table1");
datacolumn c = new datacolumn("thing");
t.columns.add(c);
ds.tables.add(t);
datarow r;
for(int i = 0; i<10;i++)
{
r = t.newrow();
r[0] = i;
t.rows.add(r);
}
this.repeater1 .datasource =ds.tables [0].defaultvIEw ;
this.repeater1.databind ();
}
private void repeater1_itemdatabound(object sender, system.web.ui.webcontrols.repeateritemeventargs e)
{
if(i%3==0!amp;!amp;i>0)
{
e.item.controls.add(new literalcontrol("</tr><tr>"));
}
i++;
}
http://www.cnblogs.com/bccu/archive/2006/10/24/538506.Html