Most likely, you overwrite the GridView after each postback, rather than binding it once and letting ViewState save the data. If you anchor the GridView every time the page is sent back, any changes you make will be destroyed and replaced with information from the database.
Only bind to load the first page (in this case):
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { GridView1.DataSource = GetSomeData(); GridView1.DataBind(); } }
After installing the above code, you can get the correct data from the TextBox:
foreach (GridViewRow row in GridView1.Rows) { TextBox txt = row.FindControl("TextBox1") as TextBox; if (txt != null) { string value = txt.Text; } }
source share