skip to content »

Rowupdating e oldvalues

rowupdating e oldvalues-8

NET 2.0 Grid View control allows us to quickly edit and delete records. Drag and drop an SQL Data Source control on the web form.However, most of the real world cases call for validating the data being edited or deleted. Open its smart tag and choose “Configure Data Source” option to start Configure Data Source wizard.

rowupdating e oldvalues-74

If the country is null then we set Cancel property of Grid View Update Event Args class to true.You can attach validation controls to the Template Fields to perform client side or server side validation.If you need more control you can also handle Row Updating or Row Deleting events of the Grid View.Next, drag and drop a Required Field Validation control below the Text Box.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”.There can be several approaches taken for validating data. On the first step of the wizard click on “New Connection” button to open a dialog as shown in Figure 1.

Enter the database details as per your setup and click on OK.

Similarly if you set country to “Bharat” it gets replaced as “India”.

In this article we learnt various ways of validating data in a Grid View control.

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.

This will convert them from Bound Field to Template Field.

These events are raised before updating and deleting the record respectively.