void gcMultiRow1_CellValidating(object sender, CellValidatingEventArgs e)
{
if (e.CellName == "Age")
{
int age = int.Parse(e.FormattedValue.ToString());
if (age < 0 || age > 100)
{
e.Cancel = true;
// Set error text to tell user why the cell validating do not pass.
this.gcMultiRow1[e.RowIndex, e.CellIndex].ErrorText = "The age should greater than 0 and less than 100.";
this.gcMultiRow1.EndEdit();
}
else
{
this.gcMultiRow1[e.RowIndex, e.CellIndex].ErrorText = string.Empty;
}
}
}
Private Sub gcMultiRow1_CellValidating(ByVal sender As Object, ByVal e As CellValidatingEventArgs) Handles gcMultiRow1.CellValidating
If e.CellName = "Age" Then
Dim age As Integer = Integer.Parse(e.FormattedValue.ToString())
If age < 0 OrElse age > 100 Then
e.Cancel = True
' Set error text to tell user why the cell validating do not pass.
Me.gcMultiRow1(e.RowIndex, e.CellIndex).ErrorText = "The age should greater than 0 and less than 100."
Me.gcMultiRow1.EndEdit()
Else
Me.gcMultiRow1(e.RowIndex, e.CellIndex).ErrorText = String.Empty
End If
End If
End Sub