Start Gridview handle rowupdating

Gridview handle rowupdating

In our example we will illustrate the use of Updating event for the validation purpose.

We need to convert these Bound Fields to Template Fields.

In order to do so select "Edit Columns..." from the smart tag of the Grid View. Select Company Name and Contact Name fields and click on "Covert this field into a Template Field" link.

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".

On the next step select Customer ID, Company Name, Contact Name and Country columns (Figure 2).

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.

We check the value entered in the Text Box using args. Especially the following events are important for validation point of view.

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.