1.取值确定TextBox在GridView的第几列,注意:
GridView的列是从0开始计数的,第一列的索引就是0,加入TextBox在第一列,那么我们可以这样
for(int i=0;i<this.GridView1.Rows.Count;i++)
{
TextBox txt = (TextBox)this.GridView1.Rows[i].Cells[0].FindControl("TextBox1");
if(txt != null)
{
string str = txt.Text; //你要做的处理
}
}
2.赋值,道理同上
for(int i=0;i<this.GridView1.Rows.Count;i++)
{
TextBox txt = (TextBox)this.GridView1.Rows[i].Cells[0].FindControl("TextBox1");
if(txt != null)
{
txt.Text = "你要赋的值";
}