After I change the DataGridView cell's value programmatically, the source cannot be updated. What can I do?
datagridview1.DataSource = bindingsource1;
datagridview1.Rows[0].Cells[0].Value = "1";
You need write back the DataSet, here below my codes
private void button2_Click(object sender, EventArgs e)
{
this.Validate();
try
{
dgvArticles.CurrentRow.Cells[1].Value = txtSubject.Text;
dgvArticles.CurrentRow.Cells[2].Value = rtbBodyContent.Text;
dgvArticles.CurrentRow.Cells[3].Value = pbPrimaryPicture.Image;
dgvArticles.CurrentRow.Cells[4].Value = pbSecondaryPicture.Image;
dgvArticles.CurrentRow.Cells[5].Value = pbThirdPicture.Image;
}
catch
{
MessageBox.Show(e.ToString());
}
AccessingNetFamerDatabase anfdArticles = new AccessingNetFamerDatabase();
if (_dsArticles!= null)
{
SqlCommandBuilder _sqlCBArticles = new SqlCommandBuilder(AccessingNetFamerDatabase._sqlDataAdapter);
AccessingNetFamerDatabase._sqlDataAdapter.Update(_dsArticles.Tables[0]);
}
}