You can get the TextBox control inside the corresponding GridView cell using the Controls or FindControl(string id) property:
TextBox txtTotal = gv.Rows[index].cells[0].Controls[0] as TextBox;
or
TextBox txtTotal = gv.Rows[index].cells[0].Controls[0].FindControl("TOTAL") as TextBox;
where index can be 0 for the first line or an iterator inside a for loop.
Alternatively, you can use the foreach loop over the rows of the GridView:
foreach(GridViewRow row in gv.Rows) { TextBox txtTotal = row.cells[0].Controls[0].FindControl("TOTAL") as TextBox; string value = txtTotal.Text;
In addition, you should keep in mind that if you create a GridView dynamically (and not declaratively in a web form), you will not be able to get this control after the postback of the page.
The Rolla article has 4 great guys from the Rolls article: Dynamic Web Controls, Callbacks, and View State
source share