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

Validating Row in winforms GFrid

1 Answer 81 Views
GridView
This is a migrated thread and some comments may be shown as answers.
yaron
Top achievements
Rank 1
yaron asked on 25 Jun 2018, 06:05 AM

Hi, 

I am very confused with validating data before sending it to the DB. 

My Grid is popultated with datatable (from Web service) and I would like to send row data each time the user finishes to edit the row (send via Web Service) and also I would like to send a new row data by using a web service call with the params as needed. 

The proble is that I do not know wich event to use sa there are a lot. 

I tried to use grid_RowsChanged but I do not know if I should also use RowValidating as rows_Changed occured before row_valdating. or should I use only rows_changed? there is also a user_added_row event... please help.. 

I want to let user finish add new row then check if everything is valid. If it is not valid I would like to prevent him from pushing data (rovalidating is the only way I have to cancel telerik grid action to add the new row or accept the current row changes. 

It is very consfusing, could you please help me. 

 

Yaron

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 25 Jun 2018, 12:09 PM
Hello, Yaron,   

RadGridView provides a convenient way to perform validation before data is committed to the underlying data source. You can validate data by handling CellValidating event which is raised by RadGridView when the current cell changes or when the cell loses input focus (when pressing Enter key). Canceling this event prevents the user from exiting the cell until a valid editor value is entered or the edit process is canceled. The RowValidating event can be used the same way to prevent the user from exiting the current row. However, the editor will be closed in this case and the value will be committed to the underlying data source. Additional information is available in the following help article: https://docs.telerik.com/devtools/winforms/gridview/editors/data-validation

In order to validate the new row's data, it is suitable to handle the UserAddingRow event. This help article gives additional information about the new row: https://docs.telerik.com/devtools/winforms/gridview/rows/new-row

Here are demonstrated several events how to update the external data source. Feel free to use this one which suits your requirement best: https://docs.telerik.com/devtools/winforms/gridview/populating-with-data/updating-the-database-with-ado.net

I hope this information helps. If you have any additional questions, please let me know. 

Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
yaron
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or