一、下面的代码实现,每行显示三列
前台代码:
<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&&i>0)
{
e.Item.Controls.Add(new LiteralControl("</tr><tr>"));
}
i++;
}
http://www.cnblogs.com/bccu/archive/2006/10/24/538506.html
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |