By default when the Grid View controls goes in edit mode, it displays Text Boxes for entering values.You can not attach validation controls directly to these Text Boxes.

gridview rowupdating event in asp net-21

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.

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

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.

There can be several approaches taken for validating data. For our example we are going to use Customers table of Northwind database. Open its smart tag and choose "Configure Data Source" option to start Configure Data Source wizard.

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.

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