请教gridview高级功能
在一个页面里GridView1现在已经显示数据,怎么在点击一个Button的时候在GridView1的head里面增加一个textbox,并给textbox赋值?谢谢
------解决方案--------------------帮顶
------解决方案--------------------protected void Button1_Click(object sender, EventArgs e)
{
TextBox t = new TextBox();
t.ID = "txtTemp ";
t.Text = "aaa ";
this.GridView1.HeaderRow.Cells[0].Controls.Add(t);
}
------解决方案--------------------顶都顶累了,,,,,,
------解决方案--------------------你说的不太具体,我估计你是要添加一个新列并在其中添加 TextBox
代码如下,希望对你有所帮助!:)
protected void Button1_Click(object sender, EventArgs e)
{
TextBox txt = new TextBox();
txt.Text = "New ";
int count = GridView1.HeaderRow.Cells.Count;
GridView1.HeaderRow.Cells.Add(new TableCell());
GridView1.FooterRow.Cells.Add(new TableCell());
GridView1.HeaderRow.Cells[count].Controls.Add(txt);
}