日期:2014-05-17 浏览次数:20479 次
TextBox tb = new TextBox();
this.GridView1.Rows[0].Cells[0].Controls.Add(tb);//在第一行第一列的单元格中加入一个textbox
this.GridView1.Columns[0].HeaderStyle.Width = new Unit(200);//修改第一列的列宽
GridView1.AutoGenerateColumns = false;
GridView1.Columns.Clear();
new int[DBReader.FieldCount].Select((_, i) => DBReader.GetName(i)).ToList()
.ForEach(f => GridView1.Columns.Add(new BoundField { DataField = f, HeaderText = f }));
GridView1.DataSource = DBReader;
GridView1.DataBind();
this.GridView1.Columns[0].HeaderStyle.Width = new Unit(200);