Gridview1 rowupdating old values
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.
Set the Control To Validate and Error message properties to the appropriate values. Up till now we used the validation controls to validate Grid View input on client and server side.
Double click on the Custom Validator control to go into the Server Validate event handler and write the following code in it. However, at times you many need more control and flexibility than that is provided by validation controls.
This will convert them from Bound Field to Template Field.
These events are raised before updating and deleting the record respectively.
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.
We will use the Custom Validator control for this purpose.
Just like we attached the Required Field Validator control to the Text Box, attach a Custom Validator to the Contact Name column. If you run the web form and try entering wrong value in the Contact Name column then you will see the error message displayed as before and the value will not be accepted by the Grid View control.
By default when the Grid View controls goes in edit mode, it displays Text Boxes for entering values.