Gridview rowupdating event handling Live sex cam no registration no restriction age

NET 2.0 Grid View control allows us to quickly edit and delete records.

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.

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.

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.

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.

Make Company Name blank and click on Update button.

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

This will display the template designer for the column as shown in Figure 6.

Next, drag and drop a Required Field Validation control below the Text Box.

203

Leave a Reply