Validating data datagrid
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.
Inside the event handler we added two validation conditions: We used the New Values collection to check the entered country.
If the country is null then we set Cancel property of Grid View Update Event Args class to true.
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.
Right click on the Grid View and select "End template editing" Run the web form.
Click on the Edit button of the Grid View so that it goes into the edit mode.
However, most of the real world cases call for validating the data being edited or deleted. Drag and drop an SQL Data Source control on the web form.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).Make Company Name blank and click on Update button.You should see an error message as shown in Figure 7.