2011-12-09 33 views
0

我想要在gridVew中添加文本框。我可以做到这一点,但是这个textBox与gridView中的每一行一起出现。我无法处理它;我甚至不能使用它的ID。我希望触及每行附带的这些文本框并获取插入到其中的值。我可以在GridView中添加文本框并获取值w

我该怎么做?

回答

0

了解所需的文本框的行和单元格,您可以将其作为常规控件检索并将其转换为文本框。

//assuming its the only control in the cell (or the first) it will be at index 0 
TextBox tb = myGridView.Rows[i].Cells[c].Controls[0] as TextBox; 

或知道的ID,你可以这样做太:

TextBox tb = myGridView.Rows[i].Cells[c].FindControl("txtID") as TextBox; 

string txtStr = tb.Text; 
0

在另一方面,你可以使用jQuery的读/操纵你的文本框,因为你会知道他们的id。

另一种方法是建立你的网格,但它会是很多额外的工作。

相关问题