This is a migrated thread and some comments may be shown as answers.

Validation On Inserting New Row

3 Answers 111 Views
GridView
This is a migrated thread and some comments may be shown as answers.
karen
Top achievements
Rank 1
karen asked on 02 Sep 2011, 04:33 PM
Hi,

The grid validates (required field validations) on the second time I hit the add button.

I noticed that when the property RowInEditMode is not null or the previous row is in edit mode, I get the validation errors on the new row. When is this property set (RowInEditMode) and how can I prevent validation when I'm just adding a new row. I already tried the CommitEdit,CommitRowEdit, ValidatesOnDataErrors to all 4 different modes, unfortunately the grid still validates. 

I hope you could help me.


Thanks,
Karen

3 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 08 Sep 2011, 07:32 AM
Hello Karen,

 May you please provide some additional information on what are those required field validations? How do you define them? 

The RowInEditMode property is set when a row of the GridView is in edit mode. 

The ValidatesOnDataErrors controls the way the data validation, provided by IDataErrorInfo and INotifyDataErrorInfo Interfaces. As you are using an external validation, then this property has nothing to do with canceling the validation. 

The classic case of asynchronous validation supported by RadGridView is via IDataErrorInfo + INotifyPropertyChanged or only INotifyDataErrorInfo interfaces. Here is a help article about validation. So if your Business Object can implement any of these interfaces then you will be able to control the validation.

Regards,
Didie
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Kris
Top achievements
Rank 1
answered on 08 Sep 2011, 09:42 AM
We are having a very closely related problem with the GridView.
We are using DataAnnotations ValidationAttributes and validation works perfectly well, however validation errors are still raised when we turn them off using ValidatesOnDataErrors, or even when IsValid is set to true during the Cell/Row Validating event.

I have noticed that Validation doesnt raise any errors if the row is in Insert mode when the validating events are fired, but the row edit is still not committed.


Is it possible to stop the gridview from validating input when dataannotations are used?
0
Dimitrina
Telerik team
answered on 13 Sep 2011, 12:55 PM
Hello Kris,

Unfortunately in this case it is not the grid that handles the validation, but the Framework.  This validation is done on the data layer and therefor the GridView may not handle it.

You could use a custom CellEditTemplate and do your custom validation there.

All the best,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
karen
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Kris
Top achievements
Rank 1
Share this question
or