Rowupdating event vb

posted by | Leave a comment

Click on the "Advanced" button and check the "Generate INSERT, UPDATE and DELETE statements" checkbox (Figure 3). Now that you have configured the SQL Data Source control let's bind it with a Grid View control. Open its smart tag and configure it as shown in Figure 4.

Here, we set the Data Source of the Grid View to Sql Data Source1. We also enable paging, sorting and editing features of the Grid View.

Make Company Name blank and click on Update button.

You should see an error message as shown in Figure 7.

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

Add Grid View1_Row Updating event handler as shown below: The Row Updating event handler receives an event argument of type Grid View Update Event Args.

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.

If the country is null then we set Cancel property of Grid View Update Event Args class to true.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.This will convert them from Bound Field to Template Field.Now from the smart tag of the Grid View choose "Edit Template" and then select "Edit Item Template" of Company Name column.

Leave a Reply

wood harris dating