Habe das folgende Problem:
wenn ich ein DataGrid in den EditModus setze:
DataGrid1.EditItemIndex = e.Item.ItemIndex;
wie lese ich dann den geänderten Text aus der TextBox aus um ihn in die DB zu schreiben?
damit geht es nicht, denn er speichert in den Variablen nur die alten Daten und nicht die neuen.
string location = ((TextBox)e.Item.Cells[0].Controls[0]).Text;
string description = ((TextBox)e.Item.Cells[1].Controls[0]).Text;
string sqlUpdate = „UPDATE location SET locationid=’“+location+"’, description=’"+description+"’ WHERE locationid=’"+editedLocation+"’";
this.sqlConnection1.Open();
this.sqlUpdateCommand1.CommandText = sqlUpdate;
this.sqlUpdateCommand1.ExecuteNonQuery();
this.sqlConnection1.Close();
this.sqlDataAdapter1.Fill(this.dataSetLocations1);
this.DataGrid1.EditItemIndex = -1;
DataGrid1.DataBind();