Given: DataGridView is bound to a BindingSource, BindingSource is bound to a table from a DataSet, DataSet gets data from a TableAdapter.
At DGV on the Event CellEndEdit "hang": "Tab1TableAdapter.Update (dataSet1);" those. after cell editing is completed we update the data in the database. But this only works if we change the value in the cell and click on another cell. If, after changing the value, press Enter, the data in the database will not be updated. Even if you create a separate button with "Tab1TableAdapter.Update (dataSet1);" nothing will happen. It is possible that the DGV does not understand that the data in it has been changed and does not transmit data to the Dataset, and therefore the update fails. Please tell me how to be.
Form1.cs
private void Form1_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'dataSet1.TAB1' table. You can move, or remove it, as needed. this.tAB1TableAdapter.Fill(this.dataSet1.TAB1); } private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) { tAB1TableAdapter.Update(dataSet1); } Form1.Designer.cs
private void InitializeComponent(){ ... ... ... this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.dataSet1 = new WindowsFormsApplication1.DataSet1(); this.tAB1BindingSource = new System.Windows.Forms.BindingSource(this.components); this.tAB1TableAdapter = new WindowsFormsApplication1.DataSet1TableAdapters.TAB1TableAdapter(); // // dataGridView1 // this.dataGridView1.AutoGenerateColumns = false; this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.iDDataGridViewTextBoxColumn, this.cLDataGridViewTextBoxColumn}); this.dataGridView1.DataSource = this.tAB1BindingSource; this.dataGridView1.Location = new System.Drawing.Point(24, 62); this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.Size = new System.Drawing.Size(478, 317); this.dataGridView1.TabIndex = 0; this.dataGridView1.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellEndEdit); // // dataSet1 // this.dataSet1.DataSetName = "DataSet1"; this.dataSet1.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema; // // tAB1BindingSource // this.tAB1BindingSource.DataMember = "TAB1"; this.tAB1BindingSource.DataSource = this.dataSet1; // // tAB1TableAdapter // this.tAB1TableAdapter.ClearBeforeFill = true; ... ... ... }