Prevent navigation until new row entry complete

Hi, How can I prevent the user from navigating to a different record, from an "add new record row", until they have entered all the required fields.

1 Reply

AD Administrator Syncfusion Team March 2, 2005 09:39 AM UTC

Try handling the RowLeave event and cancel it if you are editing the AddNew row and your required fields are not occuppied.
private void gridDataBoundGrid1_RowLeave(object sender, GridRowEventArgs e)
{
	if(this.gridDataBoundGrid1.Binder.IsAddNew && !IsRowOk(e.RowIndex))
	{
		e.Cancel = true;
	}
}

private bool IsRowOk(int row)
{
	bool ret = true;
	for(int i = 1; i < this.gridDataBoundGrid1.Model.ColCount; i++)
	{
		string s = this.gridDataBoundGrid1[row, i].Text;
		if( s == null || s.Length == 0)
		{
			ret = false;
			break;
		}
	}
	return ret;
}

Loader.
Up arrow icon