I have a dataGridView and when I do some modifcations I want to get those modified records.
For that I'm using this command
DataTable dt = ((DataTable)this.dataGridView1.DataSource).GetChanges(DataRowState.Added)
But the problem is when I add a row press save button without doing tabout..that record is not going to the database. Can anyone tell me how to overcome this issue.
Loading

Roei BarRank #1,271 · 1.4K reputationPosted Sep 22, 2009, 7:17 AM EDT
garuka20 reputationPosted Sep 22, 2009, 7:27 AM EDT
I'm not sure. The actualy problem is I have my MDI form and I'm using the MDI form save button to save the child window. So if someone do something in this form which has a dataGridView and press the save button in MDI i want to save everything.
It's working fine except for the last record, if I didn't tabout before press the save.
I'm not sure how to do that in your way.
Could you please post a lille code sample or something.
Cheers,
/G
Roei BarRank #1,271 · 1.4K reputationPosted Sep 22, 2009, 7:47 AM EDT
DataTable dt = new DataTable();
then copy the datasource like this:
dt = dgv.DataSource as DataTable;
and add an event on the DataGrid for TextChanged
on the TextChanged EVent update the dt.
by this
private void dgv_TextChanged(object sender ,CellEventArgs e)
{
//here you can look in the dgv by dgv[e.Row,e.Column] and goto dt
DataTable to update that cell
}
garuka20 reputationPosted Sep 23, 2009, 5:55 AM EDT
And also text_chaged event is fired after u tab out from the cell I belive...isn't it?