We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

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 04:39 AM

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.
Live Chat Icon For mobile
Up arrow icon