using System;
using System.Data;
public partial class _BackgroundColor:System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//生成DataTable并添加10个列
DataTable dt = new DataTable();
for(int i = 0; i < 10; i++)
{
dt.Columns.Add();
}
//往DataTable里添加20行数据
for(int i = 0; i < 20; i++)
{
dt.Rows.Add(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
}
//将DataTable绑定到GridView
gvMeiMingZi.DataSource = dt;
gvMeiMingZi.DataBind();
}
}
示例文件:
您可能感兴趣的文章: