Hello
I am working with a databound RadGridView, I would like to intercept data exceptions errors while editing but also while adding a record. At the moment Im more concerned with adding. While adding if the DataError method is called the ErrorText is set for the row, but instead of staying focused in the current cell, it deletes all data in all cells that were entered. There is an exclamation icon set in the first column of the grid when the ErrorText is set but it is overlapping the current icon.
Isnt the e.Cancel = true line supposed to cancel validation and keep the focus in the current cell till valid data is entered?
Could you provide me with a way to retain all data that was entered into the row before the error. Also to some method of indicating which cell has the error, and also how to shut off that exclamation icon when the ErrorText is set or have it be the only icon showing?
Attached are pictures to illustrate how the icon is appearing within the row and showing the tooltip with the empty record
I am working with a databound RadGridView, I would like to intercept data exceptions errors while editing but also while adding a record. At the moment Im more concerned with adding. While adding if the DataError method is called the ErrorText is set for the row, but instead of staying focused in the current cell, it deletes all data in all cells that were entered. There is an exclamation icon set in the first column of the grid when the ErrorText is set but it is overlapping the current icon.
Isnt the e.Cancel = true line supposed to cancel validation and keep the focus in the current cell till valid data is entered?
private
void
radGridView1_DataError(
object
sender, GridViewDataErrorEventArgs e)
{
e.Cancel =
false
;
if
((e.Exception)
is
System.Data.NoNullAllowedException)
{
RadGridView view = (RadGridView)sender;
if
(view.CurrentRow
is
GridViewNewRowInfo)
{
view.CurrentRow.ErrorText = e.Exception.Message;
//The following line doesnt work when adding a row, as e.RowIndex will equal -1
//(sender as RadGridView).Rows[e.RowIndex].ErrorText = e.Exception.Message;
e.ThrowException =
false
;
}
}
}
Could you provide me with a way to retain all data that was entered into the row before the error. Also to some method of indicating which cell has the error, and also how to shut off that exclamation icon when the ErrorText is set or have it be the only icon showing?
Attached are pictures to illustrate how the icon is appearing within the row and showing the tooltip with the empty record