-
November 25th, 2007, 04:06 AM
#1
DataRow.RowState
I'm trying out this article on codeproject for my DataGridView: Autosaving
http://www.codeproject.com/cs/databa...select=2075150
But none of my rows are getting saved to the database when I change to a new row or close my form.
My problem seems to be in this code :
Code:
private void UpdateRowToDatabase()
{
if (LastDataRow != null)
{
if (LastDataRow.RowState == DataRowState.Modified)
{
tblMaintenanceWorkTableAdapter.Update(LastDataRow);
}
}
}
I never get to the update function because the RowState doesn't seem to be modified, although I fill in all the columns of my row.
I also checked the LastDataRow and it is filled with a row through this code :
Code:
private void tblMaintenanceWorkBindingSource_PositionChanged(object sender, EventArgs e)
{
// if the user moves to a new row, check if the
// last row was changed
BindingSource thisBindingSource = (BindingSource)sender;
DataRow ThisDataRow = ((DataRowView)thisBindingSource.Current).Row;
if (ThisDataRow == LastDataRow)
{
// we need to avoid to write a datarow to the
// database when it is still processed. Otherwise
// we get a problem with the event handling of
//the DataTable.
throw new ApplicationException("It seems the" +
" PositionChanged event was fired twice for" +
" the same row");
}
UpdateRowToDatabase();
// track the current row for next
// PositionChanged event
LastDataRow = ThisDataRow;
}
so what do you guys think I'm still doing wrong?
Did I oversee something in the article?
-
November 27th, 2007, 10:24 AM
#2
Re: DataRow.RowState
Noone out there that can help me or point me in the right direction?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|