XXX Chats

Pussy hookup sites

New value in gridview rowupdating event

This way you can attach client side validation controls to the Grid View columns.Let's proceed further by validating on the server side.This tells Grid View that the event handler should be cancelled.

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.

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.

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.

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.

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.

Comments New value in gridview rowupdating event