I have a radGridView on a form which has cell and row validation implemented. No problem with that, works well.
The problem arises when I leave a row incomplete and then click on the Save button elsewhere on the form. The RowValidating code snippet below does not work, because once the focus moves away from the GridView to the Save button, the 'if (row != null)' check always returns false, and the RowValidating code is never executed.
How can I retain focus in the grid to ensure that the entire grid validates before allowing the user to leave the grid?
The problem arises when I leave a row incomplete and then click on the Save button elsewhere on the form. The RowValidating code snippet below does not work, because once the focus moves away from the GridView to the Save button, the 'if (row != null)' check always returns false, and the RowValidating code is never executed.
private
void
radGridView1_RowValidating(
object
sender, RowValidatingEventArgs e)
{
var row = e.Row
as
GridViewDataRowInfo;
if
(row !=
null
)
{
var value = row.Cells[
"cboUnit"
].Value.ToString();
if
(
string
.IsNullOrEmpty(value))
{
e.Cancel =
true
;
row.ErrorText =
"Unit Number is a required field"
;
}
else
{
row.ErrorText =
string
.Empty;
}
}
}
How can I retain focus in the grid to ensure that the entire grid validates before allowing the user to leave the grid?