G
Guest
I've written code that uses a DataGrid to display the data in a table. When
I am adding a new row to the table I've hooked into the ColumnChanged event
to verify that the data entered is correct. With a detached(new) row I get
this error when I have to reject the changes the user entered in the grid.
An unhandled exception of type 'System.Data.RowNotInTableException' occurred
in system.windows.forms.dll
Additional information: This row has been removed from a table and does not
have any data. BeginEdit() will allow creation of new data in this row.
Here is the function:
private void OnColumnChanged(object sender,DataColumnChangeEventArgs e) {
if (e.Column.ColumnName.ToLower().Equals("ety_id")) {
if (!m_etyId.Equals(e.Row[e.Column.ColumnName].ToString())) {
MessageBox.Show("Ety Id Entered is not Valid. Row will be reset","12b1
Processing");
try {
if (e.Row.RowState != DataRowState.Detached)
e.Row.RejectChanges();
else {
e.Row.BeginEdit();
e.Row.RejectChanges();
e.Row.EndEdit();
}
}
catch (Exception e1) {
System.Diagnostics.Debug.WriteLine(e1.ToString());
}
return;
}
}
Any help out there that would tell me how to reset the data in the grid? In
other words the user has entered lousy data and I want it to go bye bye.
Thanks
Stan
I am adding a new row to the table I've hooked into the ColumnChanged event
to verify that the data entered is correct. With a detached(new) row I get
this error when I have to reject the changes the user entered in the grid.
An unhandled exception of type 'System.Data.RowNotInTableException' occurred
in system.windows.forms.dll
Additional information: This row has been removed from a table and does not
have any data. BeginEdit() will allow creation of new data in this row.
Here is the function:
private void OnColumnChanged(object sender,DataColumnChangeEventArgs e) {
if (e.Column.ColumnName.ToLower().Equals("ety_id")) {
if (!m_etyId.Equals(e.Row[e.Column.ColumnName].ToString())) {
MessageBox.Show("Ety Id Entered is not Valid. Row will be reset","12b1
Processing");
try {
if (e.Row.RowState != DataRowState.Detached)
e.Row.RejectChanges();
else {
e.Row.BeginEdit();
e.Row.RejectChanges();
e.Row.EndEdit();
}
}
catch (Exception e1) {
System.Diagnostics.Debug.WriteLine(e1.ToString());
}
return;
}
}
Any help out there that would tell me how to reset the data in the grid? In
other words the user has entered lousy data and I want it to go bye bye.
Thanks
Stan