gridview 有点麻烦 可以用repeater
protected void btnCreate_Click(object sender, EventArgs e)
{
try
{
string name = Name.Text;
DataTable _dtPerons = buildDt(a,name,dept,date);
Repeater1.DataSource = _dtPerons;
Repeater1.DataBind();
}
catch
{
}
}
private DataTable buildDt( string name )
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("name"));
for (int i = 1; i <= num; i++)
{
DataRow dr = dt.NewRow();
dr["name"] = name;
dt.Rows.Add(dr);
}
return dt;
}
复制datagridview的行格式,并添加DataRow的实例化。
添加新列