Asp net datagrid rowupdating
Enter the database details as per your setup and click on OK.
On the next step select Customer ID, Company Name, Contact Name and Country columns (Figure 2).
Out of these events Row Updating and Row Deleting are possibly the most common ones.
These events are raised before updating and deleting the record respectively.
Here, our validation criteria is that the entered name must not contain title of courtesy (Mr./Mrs./Ms.). That is when you can handle certain events of Grid View control.
If the country is null then we set Cancel property of Grid View Update Event Args class to true.This way you can attach client side validation controls to the Grid View columns.Let's proceed further by validating on the server side.This tells Grid View that the event handler should be cancelled.The New Values collection is read/write collection and in the second if condition we set the Country to India. You will find that the data is not accepted by the Grid View.By default when the Grid View controls goes in edit mode, it displays Text Boxes for entering values.You can not attach validation controls directly to these Text Boxes.Make Company Name blank and click on Update button.You should see an error message as shown in Figure 7.Set the Control To Validate property of Required Field Validator control to Text Box1 (i.e. Also, set its Error Message property to "Please enter company name".Note that by default all validation controls validate on the client side.