【动态生成DataGrid】
klmy 2003-12-31 02:24:23 请问如何动态生成动态的DataGrid,就是绑定的字段,是从数据库中,取出来的!!
string[] hz=temphz.Split(new char[]{','});//数据库的字段汉字名称
string[] py=temppy.Split(new char[]{','});//数据库的字段名
int l=hz.Length;
for (int m=0;m<hz.Length;m++)
{
BoundColumn bb= new BoundColumn();//这里有警告信息
bb.HeaderText=hz[m].ToString();
bb.DataField=py[m].ToString();
DataGrid3.Columns.Add(bb);
}
DataGrid3.DataBind();
这样数据可以出来,但是,有警告,有没有别的办法呀??